CodeIgniter Forums

Full Version: "24 hours ago" in Unix
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]ShoeLace1291[/eluser]
I need to be able to get what the date and time would have been 24 hours from the current time displayed in a unix. How do I do this in code igniter?

El Forum

[eluser]Colin Williams[/eluser]
Just a little 3rd grade math.

Code:
$one_day_ago = time() - (60 * 60 * 24);

El Forum

[eluser]danmontgomery[/eluser]
Or, for the lazy:

Code:
$yesterday = strtotime("24 hours ago");

http://php.net/manual/en/function.strtotime.php

El Forum

[eluser]Colin Williams[/eluser]
strtotime('-1d') might work too.