It'll also convert "0:45" into "00:00AM" (and "0:23" into "11:00PM").
No, I wouldn't. Leaving out the leading zero is pretty common where I'm from.
// Preserve 2400h time by changing leading zeros to 24.
time = time.replace( /^0*[0:]/, '24' );That converts "0800" into "00:00AM".
time = time.replace( /^0*(0:)+/, '24' );