禁用ExtJS中的时区转换 [英] Disabling the timezone conversion in ExtJS

查看:310
本文介绍了禁用ExtJS中的时区转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果呈现JavaScript / ExtJS Date对象,则始终相对于浏览器。

例如,时间戳 4102338600000 将被渲染为 Thu Dec 31 2099 00:00:00 GMT + 0530(印度标准时间)'与IST分区浏览器,将减少一天在EST分区浏览器。



我从网络上的文章中尝试了几种方式,如抵消时区等,但看不到直接的选项。



我们的应用程序需要统一的日期,以GMT / UTC /其他格式说,无论时区如何。



在应用程序代码中,使用以下的100个地方提交日期:

 格式:'dM-Y',

有什么事情要做同样的事情,但是使用UTC而不是本地转换?

解决方案

  1. 将时间戳发送到服务器以及时区详细信息。

  2. 在服务器端,根据时区,获取要保存的UTC日期。

  3. 在检索时,按照请求的参数发送时区,并相应地为其提取日期。

很长,但应该工作: - )


When a JavaScript/ExtJS Date object is rendered, the date is always relative to the browser.

E.g the timestamp 4102338600000 would be rendered as 'Thu Dec 31 2099 00:00:00 GMT+0530 (India Standard Time)' with IST zoned browser and will be one day less in EST zoned browser.

I tried couple of ways from the articles on the net like offsetting the timezone, etc but don't see straightforward option.

Our application needs uniform date, say in GMT/UTC/other format, irrespective of timezone.

In app code, 100's of places, below is used to render date :

format : 'd-M-Y',

Is there something to do the same thing but with UTC instead local conversion?

解决方案

Probably you could do below :

  1. Send the timestamp to server along with the Timezone details.
  2. On server side, based on the timezone, get the UTC date to save.
  3. While retrieving, send the timezone as in requested params and have the date fetched accordingly for that.

Little lengthy, but should work :-)

这篇关于禁用ExtJS中的时区转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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