What time zone does the JavaScript new Date() use?

后端 未结 4 1807
故里飘歌
故里飘歌 2020-12-18 20:57

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\"
         


        
4条回答
  •  旧时难觅i
    2020-12-18 21:33

    As other said, JavaScript uses clients system time, but you can create date object from server time, so every client will get the same current time.

    var date = new Date("");
    

    It will work only on page load. If you want to check later for dates still valid, then you need to synchronize current date with server date every couple of seconds.

提交回复
热议问题