Consistent date / time date of the client using JavaScript (including time zones)

My question relates to this quote from a date guide in JavaScript:

Note: parsing date strings using a date constructor (and Date.parse, they are equivalent) is strongly discouraged due to browser differences and inconsistencies.

new Date('2016-04-14')for the user was Wed Apr 13 2016 17:00:00 GMT-0700 (US Mountain Standard Time)on which he was supposed to use .toUTCString().

How to handle this if users are in many different time zones?

+2
source share
2 answers

new Date().getTime();returns an integer value as the time on the client machine since 1970 January 1 .

, , , (IE, Chrome, Mozilla - ).

, , .

, getTimezoneOffset API

var x = new Date();
var currentTimeZoneOffsetInHours = x.getTimezoneOffset() / 60;

new Date().getTime(); .

+1

 new Date().getTime();

1970-01-01 , . .

, . , , 01/01/2010, b 01/01/2010, 1970-01-01

,

+1

All Articles