M
M
mrSeller2018-03-06 16:47:39
JavaScript
mrSeller, 2018-03-06 16:47:39

Mobile browsers give Invalid Date when parsing GMT format - how to format date?

I get a string Wed Dec 20 2017 13:43:03 GMT+0300, on desktops it is perfectly parsed using Date.parse (), but in mobile browsers the method returns Invalid Date.

How else can you turn this string into milliseconds?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmitrygavrish, 2018-03-06
@mrSeller

In order not to fence the bike, you can use ready-made solutions. Most Searched:
https://www.npmjs.com/package/moment
momentjs.com/docs/#/parsing/string

var moment = require('moment');
var day = moment("Wed Dec 20 2017 13:43:03 GMT+0300");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question