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

后端 未结 4 1799
故里飘歌
故里飘歌 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:21

    By default, JS will use your browser timezone, but if you want to change the display, you can for example use the toString() function ;)

    var d1=new Date();
    d1.toString('yyyy-MM-dd');       //returns "2015-03-27" in IE, but not FF or Chrome
    d1.toString('ffffdd, MMMM ,yyyy')  //returns "Friday, March 27,2015" in IE, but not FF or Chrome
    

提交回复
热议问题