Javascript new Date()使用什么时区? [英] What time zone does the Javascript new Date() use?

查看:1637
本文介绍了Javascript new Date()使用什么时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#应用程序,它在JSON中返回一个身份验证令牌的过期日期,如下所示:

I have a C# application that return in JSON an expiration date of an authentication token like this:

"expirationDate":"Fri, 27 Mar 2015 09:12:45 GMT"

在我的TypeScript中,我检查日期在这里仍然有效:

In my TypeScript I check that the date is still valid here:

isAuthenticationExpired = (expirationDate: string): boolean => {
    var now = new Date().valueOf();
    var exp: any = Date.parse(expirationDate).valueOf();
    return exp - now <= 0;
};

我想知道的是什么时区 new Date() 在返回日期时使用?

What I would like to know is what time zone does new Date() use when it is returning a date?

推荐答案

JavaScript将使用客户端的本地时间,但它也会有UTC / GMT方法。以下内容来自Mozilla:

JavaScript will use the client's local time but it also has UTC / GMT methods. The following is from Mozilla:


JavaScript Date对象支持许多UTC(通用)方法以及本地时间方法。 UTC,也称为格林威治标准时间(GMT),是指世界时间标准设定的时间。本地时间是执行JavaScript的计算机所知的时间。

The JavaScript Date object supports a number of UTC (universal) methods, as well as local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the time as set by the World Time Standard. The local time is the time known to the computer where JavaScript is executed.

参考: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

这篇关于Javascript new Date()使用什么时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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