javascript - jQuery format time to remove seconds and add AM or PM -
i have time: 02:00:00
, how format 2:00pm
i have tried:
var time = new date(z.app_time), h = time.gethours(), m = time.getminutes();
but h returns nan, same m
one way:
var time = "02:00:00".split(":"), h = +time[0], p; if (h > 12) { h -= 12; p = "pm"; } else { h = h || 12; p = "am"; } var t = h + ":" + time[1] + p;
javascript jquery
No comments:
Post a Comment