【发布时间】:2016-07-24 09:15:21
【问题描述】:
我想从他的时区获取用户当地时间。为此,我使用以下代码:
<script type="text/javascript">
$(document).ready(function(){
var tz = jstz.determine(); // Determines the time zone of the browser client
var timestamp = '<?php echo $value->created_at->sec; ?>';
var localtime = moment.unix(timestamp).utcOffset(tz).format('MM/DD/YY hh:mm');
console.log(timestamp+"==>"+tz.name()+'==>'+localtime);
});
</script>
我从这段代码中获得了准确的时区,但无法从当前时区获得实际时间。 我已经在我的代码中包含了 moment.js 和 jstz.js。 如何获取用户当地时间?
【问题讨论】:
标签: php jquery timezone momentjs