How to use momentjs to format to 1pm when there is no minutes and 1.30pm if there is minutes?
let start = MOMENT(startDate).format("MMM D (ddd): h.mma").toString();
What is the easiest way to do this?
The correct syntax is:
let date = moment(startDate);
let start = date.get('minutes') === 0 ? date.format("MMM D (ddd): ha") : format("MMM D (ddd): h.mma");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.