...

View Full Version : Timestamp gerenation [for php to use]



jeanpaul1979
12-24-2006, 12:46 PM
Hi, i've been experimenting with this but have yet to find a solution if there is one. Below you can see how far i have come. They both return the time passed since the epoch but still i get different values, any idea why?



<script>
//UTC() returns milliseconds, mktime returns seconds
document.write(Date.UTC(1979, 09, 01) / 1000);
</script>

<?php
echo '<br>';
echo mktime(0, 0, 0, 09, 01, 1979);
?>

output:
307584000
281314800

dumpfi
12-24-2006, 01:06 PM
I've used this:
<script type="text/javascript">
//UTC() returns milliseconds, mktime returns seconds
document.write(Date.UTC(1979, 8, 0, 23) / 1000);
</script>

<?php
echo '<br>';
echo mktime(0, 0, 0, 9, 1, 1979);
?>and got the same output from both.

Seems like Date()'s month and day values are 0-based, and that my server has wrong time zone settings.

Oh, and use 9 instead of 09, or PHP tries to treat the number as octal (and fail).

dumpfi



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum