So I have a block of PHP code, and I simply wanted to have a UNIX timestamp for the current date, and one that is 25 minutes earlier. The UNIX timestamp changes accordingly, but when I use each timestamp and convert it to a formatted date with the date(‘M d, Y A — h:m:s’,$current) or date(‘M d, Y A — h:m:s’,$old), both times turn out exactly the same. It seems a change greater than 29 minutes works, but I’m not sure why. And the second part of the question: with using time() and date() and even setting the timezone to my own, the time it returns is about 20-30 minutes behind, and this also concerns me.
<?
date_default_timezone_set('MST');
$current = time();
$old = time() - (25 * 60);
echo $current . ' - ' . $old; // Prints 1330473445 - 1330471945
echo date('h:m:s A -- M d, Y',$current); // 04:02:25 PM -- Feb 28, 2012
echo date('h:m:s A -- M d, Y', $old); // 04:02:25 PM -- Feb 28, 2012
?>
This is how it prints on my screen. Different UNIX timestamps, but same formatted date. And I suppose you mean system clock as in the one I need to edit via BIOS. As far as the clock on my computer is concerned, that’s what I was comparing it to.
Update
Solved. Used an ‘m’ for seconds rather than the ‘i’
The reason is that you used “h:m:s”
m is not “minutes” m = month
i = minutes
I know it’s evil, I just fell for it myself for a while 😉
Here the docs: http://www.php.net/manual/de/function.date.php