Difference between Date.parse() and .getTime()

前端 未结 4 906
隐瞒了意图╮
隐瞒了意图╮ 2021-01-04 11:33

What\'s the main difference between:

dt = new Date();
ms = Date.parse(dt);

and

dt = new Date();
ms = dt.getTime();
<         


        
4条回答
  •  自闭症患者
    2021-01-04 12:01

    Date.parse(dt)

    The parse function applies the ToString operator to its argument and interprets the resulting string as a date; it returns a number, the UTC time value corresponding to the date. The string may be interpreted as a local time, a UTC time, or a time in some other time zone, depending on the contents of the string.

    getTime()

    Returns the numeric value corresponding to the time for the specified date according to universal time.

提交回复
热议问题