I am receiving a string containing a datetime from a web service that is formatted as dd/MMM/yyyy hh:mm:ss it is not possible to change the web service output to match this JavaScript applications needs.
For the sake of simplicity I am replacing the web service data with hardcoded Strings that have their values below.
// The raw input from the web service
var dateOne = new Date("04/Mar/2020 08:00:00");// Invalid Date {}
// After .replace to make it valid
var dateTwo = new Date("04-Mar-2020 08:00:00");// Sat Mar 04 2000 10:00:00
dateOne is invalid (Used to be valid but recently has been proving difficult)
dateTwo is valid but incorrect (Time change from 8 to 10 is correct based on time zone but my time zone is not 20 years in the past)
If anyone could point me in the right direction that would be much appreciated. Thank you in advance.
dd/MMM/yyyy hh:mm:ssnotdd/MM/yyyy hh:mm:ssnew Date("04 Mar 2020 08:00:00");seems to work (but I wouldn't rely on it)new Date("04-Mar-2020 08:00:00")isWed Mar 04 2020 08:00:00 GMT+0200 (Eastern European Standard Time)andnew Date("04/Mar/2020 08:00:00")isWed Mar 04 2020 08:00:00 GMT+0200 (Eastern European Standard Time). So, which is actually the problem ?