2

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.

1
  • 1
    How about you find a way to delete T in the date and replace with a space, then the last part, add a "+" and delete the last letter Commented Dec 20, 2020 at 19:01

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.