Where does JavaScript get a new Date() from

后端 未结 4 588
生来不讨喜
生来不讨喜 2021-01-11 16:37

Where does JavaScript get a new Date() from?

Is it based on the client\'s local computers time settings or something else?

I can\'t find anywhere only where

4条回答
  •  误落风尘
    2021-01-11 17:14

    It is the client (user') system date. The syntax is:

    new Date();
    new Date(value);
    new Date(dateString);
    new Date(year, month[, date[, hours[, minutes[, seconds[, milliseconds]]]]]);
    

    The Date object is a datatype built into the JavaScript language. Date objects are created with the new Date( ) as shown below.

    Once a Date object is created, a number of methods allow you to operate on it. Most methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object, using either local time or UTC (universal, or GMT) time.

    The ECMAScript standard requires the Date object to be able to represent any date and time, to millisecond precision, within 100 million days before or after 1/1/1970. This is a range of plus or minus 273,785 years, so JavaScript can represent date and time till the year 275755. Reference URL : https://www.tutorialspoint.com/javascript/javascript_date_object.htm

提交回复
热议问题