var string = "14/2/2018 6:00 pm";
How to convert the String variable to Date format with UTC Time zone? i try this var x = moment.tz("16/2/2018 7:00 pm", "UTC").format(); output: x : Invalid Date
var string = "14/2/2018 6:00 pm";
How to convert the String variable to Date format with UTC Time zone? i try this var x = moment.tz("16/2/2018 7:00 pm", "UTC").format(); output: x : Invalid Date
You will find it here: https://momentjs.com/docs/
For instance:
Unless you specify a time zone offset, parsing a string will create a date in the current time zone.
moment("2010-10-20 4:30", "YYYY-MM-DD HH:mm"); // parsed as 4:30 local time moment("2010-10-20 4:30 +0000", "YYYY-MM-DD HH:mm Z"); // parsed as 4:30 UTC
=>
string += ' +0000';
moment(string, 'DD/M/YYYY h:mm a Z');