...

View Full Version : print time yesteraday 7am and today 7am in UNIX timestamp



coding_begins
09-15-2011, 04:05 PM
I have to two variables $cronlast and $cronnow in my php code.
I need to have the time 7am of previous day in $cronlast variable and 7am today in $cronnow variable.
I need the time in UNIX timestamp format.
So everyday when I print the variable I should have:

$cronlast=7am Yesterday(in Unix Timestamp)
$cronnow=7am Today(in Unix Timestamp)

I would appreciate any help.

kbluhm
09-15-2011, 04:07 PM
http://www.php.net/strtotime


$cronlast = strtotime( 'yesterday 7:00 AM' );
$cronnow = strtotime( 'today 7:00 AM' );

coding_begins
09-15-2011, 04:09 PM
thanks

Fou-Lu
09-15-2011, 04:11 PM
strtotime can do that:


$todayAt7 = strtotime('07:00');
$yesterdayAt7 = strtotime('yesterday 07:00');



Not even a close beat today :P



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum