How to format own time in moment.js?

I tried moment.time(column.start_time).format("hh:mm A"), but he gave me an error.

I have a time field value in the "15:30:00" field that needs to be formatted as "03:30 PM".

+4
source share
1 answer

You need to add the format string to the function momentbecause your date is not a valid ISO date.

var time = "15:30:00";
var formatted = moment(time, "HH:mm:ss").format("hh:mm A");
console.log(formatted); 
<script src="https://momentjs.com/downloads/moment.min.js"></script>
Run codeHide result
+7
source

Source: https://habr.com/ru/post/1659688/


All Articles