I would like to have a javascript date object having its time set according to the web server.
<script type="text/javascript">
var date=new Date();
date.setTime(<?php echo time() ?>);
ale开发者_StackOverflowrt(date.toString()); //displays the date and time according to the timezone set on the client's computer
</script>
Is the above code reliable?
Many thanks to you all.
I think it's not.
Since Javascript's setTime()
works with milliseconds and PHP's time()
works with seconds.
You'll need to add some stuff to make it works ;) I'll let you find out what.
精彩评论