gpt4 book ai didi

php - 在 PHP 和 javascript 中使用 time() 和 setTime() 函数

转载 作者:可可西里 更新时间:2023-11-01 00:52:07 25 4
gpt4 key购买 nike

我想要一个 javascript 日期对象,其时间根据网络服务器设置。

<script type="text/javascript">

var date=new Date();

date.setTime(<?php echo time() ?>);

alert(date.toString()); //displays the date and time according to the timezone set on the client's computer

</script>

上面的代码靠谱吗?

非常感谢大家。

最佳答案

我认为不是。

Javascript's setTime()使用毫秒和 PHP's time()使用秒。

您需要添加一些东西才能使其正常工作 ;) 我会让您知道是什么。

关于php - 在 PHP 和 javascript 中使用 time() 和 setTime() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5003874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com