简体   繁体   中英

Weird date/time discrepancy?

I've got an input on a webpage where the user is supposed to enter a date / time in a standard format, ie

16/09/2014 18:00

That value is then passed into the following snippet of code:

var date = new Date(Date.parse(userDate))

where userDate is the input. Then I send that date as part of an AJAX request:

var request = {
    ...
    "date" : date.toISOString()
    ...
    };

However, when I look at the request sent by my browser, date equals 2015-04-09T16:00:00.000Z .

Can someone explain why this happens?

确保根据MDN文章Date.parse()使用RFC2822或ISO 8601格式。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM