Question

I want to be able to format the time data that i get from SQL server time datatype with moment.js what i get is "PS12H:30M" when i try to format that with moment.js i get "Invalid Date", can you please help me?

Javascript

moment("PS12H:30M").format('hh:mm A');

Database

[from]               TIME (1)     NOT NULL
[to]                 TIME (1)     NOT NULL
Was it helpful?

Solution

You have to parse the String, since "PS12H:30M" isn't a recognized format. Pass a parse String as the second parameter to moment, like this:

moment("PS12H:30M", "HH:mm").format('hh:mm A');

"12:30 PM"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top