I want to convert Date
object with local timestamp to Date
"object" with UTC timestamp. One of the methods I have found is as follows:
var d = new Date(); //gives Date object with local timezone
var s_str_utc = d.toUTCString(); //converts it to UTC timezone but
//is no longer an object but a string
Is there a function to convert directly to object instead. I can always use regex and other stuff to get date and time from s_str_utc
but that wont be an elegant way of doing it.
var moment = require("moment");
var d = moment(newDate);
var utc = d.utc();
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.