Reputation: 39
In my application I have date coming in an ISO String format: '2020-12-20T15:21:28.411Z' In the database the value is stored as: '2020-12-20 15:21:28+411'.
So how can I convert '2020-12-20T15:21:28.411Z' -> '2020-12-20 15:21:28+411'.
I don't want to use moment.js and .toLocaleString() does not work.
Upvotes: 2
Views: 40
Reputation: 6180
Assuming your date is in the string format, you can replace the dot with a + and the T with a space, then chop off the last character:
yourDate.replace(/\./g,"+").replace(/T/g," ").slice(0,-1)
Upvotes: 1