我可以通过Javascript在浏览器中设置本地时区吗? [英] Can I set the local timezone in my browser via Javascript?

查看:136
本文介绍了我可以通过Javascript在浏览器中设置本地时区吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以通过新的Date()获取本地时区偏移.getTimeZoneOffset()。但Javascript从哪里获得这些信息?有没有办法可以设置它,以便所有未来的Date对象都有我想要的偏移量?我尝试在Firebug中搜索DOM,但找不到任何东西。

I know I can get the local timezone offset via new Date().getTimeZoneOffset(). But where did Javascript get that information? Is there a way I can set it, so that all future Date objects have the offset I want? I tried searching the DOM in Firebug, but couldn't find anything.

我想要完成的是将纪元时间转换为可读格式,但无论浏览器的操作系统设置如何,它都需要在US / Central中。因为我使用美国/中环,所以它与GMT没有固定的区别。因此,为什么我不能告诉Javascript我实际上在美国/中央?而不是一堆超级讨厌的转换步骤?

What I am trying to accomplish is converting epoch times to readable format, but it needs to be in US/Central, no matter what the browser's OS setting. Because I am using US/Central, it's not a fixed difference from GMT. So instead of a bunch of super nasty conversion steps, why can't I just tell Javascript that I'm actually in US/Central?

推荐答案


我知道我可以通过新的Date()获取本地时区偏移.getTimeZoneOffset()。但Javascript从哪里获得这些信息?

I know I can get the local timezone offset via new Date().getTimeZoneOffset(). But where did Javascript get that information?

ECMAScript的实现预计将决定当地时区调整。


是有一种方法我可以设置它,以便所有未来的Date对象都有我想要的偏移量吗?

Is there a way I can set it, so that all future Date objects have the offset I want?

否。


因此,为什么我不能告诉Javascript我实际上是在美国/中环?而不是一堆超级讨厌的转换步骤?

So instead of a bunch of super nasty conversion steps, why can't I just tell Javascript that I'm actually in US/Central?

您是否考虑过使用图书馆

这篇关于我可以通过Javascript在浏览器中设置本地时区吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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