strtotime("now") question
the following program shows that strtotime("now") doesn't give out the second of yyyy-mm-dd hh:mm:ss format.
PHP Code:
<?
$strstart = strtotime("2008-08-11 01:21:41");
$strend = strtotime("2008-08-11 02:03:41");//please change the time to current time
$now = strtotime("now");
echo '$strstart: '.$strstart."<br/>";
echo '$strend: '.$strend."<br/>";
echo '$now: '.$now."<br/>";
echo '$strend-$strstart: ';echo $strend-$strstart."<br/>";
echo '$strstart-$strend: ';echo $strstart-$strend."<br/>";
echo '$strstart-$now: ';echo $strstart-$now."<br/>";
echo '$now-$strstart: ';echo $now-$strstart."<br/>";
echo "end-start minute:";echo ($strend-$strstart)/60;
echo "<br/>now-start minute:";echo ($now-$strstart)/60;
?>
Result:
$strstart: 1218417701
$strend: 1218420221
$now: 1218391429
$strend-$strstart: 2520
$strstart-$strend: -2520
$strstart-$now: 26272
$now-$strstart: -26272
end-start minute:42
now-start minute:-437.866666667
my expected result is want to see $strend-$strstart: 2520 and 42 minute.
:wave:
Re: strtotime("now") question
it does show 42 minutes. :confused: Divide the result by 60.
Re: strtotime("now") question
ah..sorry, I forgot to give my situation..:p
Now, I save "2008-08-11 01:21:41" into a column which type is date.
"select regdate from member"
I will get the $starttime = "2008-08-11 01:21:41"...Then I will use strtotime("now") to get the second of current time, such as $now = "2008-08-11 02:21:41"..
then $now-$starttime = 3600..But I meet the problem at the first post