I have an API which gives the date format like 01/04/2020 00:17:26
and we are using the JavaScript code below:
function getLocalTime(timestamp){
try {
let localTime = new Date(timestamp.replace('at ','') + ' GMT+530');
return localTime;
} catch(e){
return timestamp;
}
}
vat date = getLocalTime('01/04/2020 00:17:26');
console.log(date);
The above code is returning Sat Jan 04 2020 00:17:26 GMT+0530 (India Standard Time)
But expected result will be as like Wed Apr 01 2020 00:17:26 GMT+0530 (India Standard Time)
Please help us with this.