sidsel wrote:Why not use gmdate?
GMT and UTC is the same
gmdate() returns a string...i need an integer.
I tried gmmktime() but was getting some WEIRD stuff. Anybody know why? This code:
<?
echo 'time zone offset of this machine in seconds:' . date('Z') . '<br>';
echo 'time zone offset of this machine in hours:' . intval(date('Z'))/3600 . '<br>';
$now = time();
echo 'right now on this machine which is in New Jersey:' . date('Y-m-d H:i:s', $now) . '</p>';
$utc_time = $now - intval(date('Z', $now));
echo 'utc_time:' . $utc_time . '<br>';
echo 'utc time date:' . date('Y-m-d H:i:s', $utc_time) . '</p>';
$gm_now = gmmktime();
echo 'gmmktime:' . $gm_now . '<br>';
echo 'which is:' . date('Y-m-d H:i:s', $gm_now) . '<br>';
echo 'gm date:' . gmdate('Y-m-d H:i:s') . '<br>';
?>
Has this output:
time zone offset of this machine in seconds:-18000
time zone offset of this machine in hours:-5
right now on this machine which is in New Jersey:2006-11-17 00:42:22
utc_time:1163760142
utc time date:2006-11-17 05:42:22
gmmktime:1163724142
which is:2006-11-16 19:42:22
gm date:2006-11-17 05:42:22
I'm thinking maybe I don't understand gmmktime(). Or it's buggy. or something.
Weedpacket, I just know you're trying to make me cry. Not because you're mean but because you like to expose just how far short of reality our oversimplifications are. I've always pretty much blocked out the whole Gregorian/Julian/whatever nonsense. When they say Ceaser died on the Ides of March that's good enough for me.
But for my current chore, I need to know that my code will return the same value regardless of what it's local time is or whether it observes DST. Let's assume that the time on the server is set accurately/appropriately for the local time zone. The reason for all this is that some server in India wants to refer users to my machine with some authorization credentials including the current time. I want to make sure credentials expire after a short amount of time so we need a common concept of time accurate to approximately 1 minute.