本文介紹了設(shè)置全球時區(qū)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我正在使用 Moment.js 來處理我的 Web 應(yīng)用程序中的日期.服務(wù)器以 UTC 毫秒為單位返回所有日期.現(xiàn)在,我必須顯示應(yīng)用特定時區(qū)的日期(基于用戶設(shè)置).
I am using Moment.js to handle dates in my web application. The server returns all the dates in milliseconds UTC. Now, I have to display the dates applying a specific timezone (based on the user settings).
有沒有辦法全局設(shè)置時區(qū),而不是更改所有對 momentjs 的調(diào)用來處理它??/p>
Is there any way to set the timezone globally instead of changing all the calls to momentjs to handle it?
推薦答案
您可以設(shè)置Moment 中的默認時區(qū) 使用:
moment.tz.setDefault(String);
例如
moment.tz.setDefault("America/New_York");
這篇關(guān)于設(shè)置全球時區(qū)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!