How do you convert a JavaScript date to UTC?

后端 未结 29 2085
无人共我
无人共我 2020-11-22 00:50

Suppose a user of your website enters a date range.

2009-1-1 to 2009-1-3

You need to send this date to a server for some processing, but th

29条回答
  •  悲哀的现实
    2020-11-22 01:04

    This function works beautifully for me.

    function ParseDateForSave(dateValue) {
        // create a new date object
        var newDate = new Date(parseInt(dateValue.substr(6)));
    
        // return the UTC version of the date
        return newDate.toISOString();
    }
    

提交回复
热议问题