开发者

Using time() and setTime() functions in PHP and javascript

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜