如何使用 jquery 获取用户时区? [英] How to get user timezone using jquery?

查看:25
本文介绍了如何使用 jquery 获取用户时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 'Asia/Calcutta''Australia/Darwin'

我在 myserver 上安装了 php,它的时间设置为 'UTC'

I have php installed on myserver and its time set to 'UTC'

推荐答案

检测时区偏移可以使用这个函数:

For detecting timezone offset you can use this function:

function get_time_zone_offset( ) {
  var current_date = new Date();
  return parseInt(-current_date.getTimezoneOffset() / 60);
}

您可以在这里查看示例

这篇关于如何使用 jquery 获取用户时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆