0
new Date().toLocaleString() --> "‎24‎/‎09‎/‎2015‎ ‎10‎:‎14‎:‎00‎ ‎PM"
new Date("2015-09-24 09:38:32.639").toLocaleString() --> "Invalid Date"

How can I format a date object from a timestamp in string format?

SOLUTION: At the end I got it fixed changing my date type in the server from DateTime to Instant, js will atomatically add zone offset automatically from a timestamp and will format the dates in the right way.

NOTE: I know this question is duplicated, however the solution proposed is different and may help other users to get a different approach to their code.

0

1 Answer 1

1
var myDate = "2015-09-24 09:38:32.639";

new Date(myDate.replace(/-/g,"/")).toLocaleString()

Now it's working fine

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for your quick response but this is not working for internet explorer edge...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.