Javascript examples for Date Operation:Minute
add 30 minutes to time as hours and minutes
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w ww .java 2s . c o m function addMinutesToTime(time, minsAdd) { function z(n){ return (n<10? '0':'') + n;}; var bits = time.split(':'); var mins = bits[0]*60 + +bits[1] + +minsAdd; return z(mins%(24*60)/60 | 0) + ':' + z(mins%60); } result=addMinutesToTime('6:31',30); console.log(result); result=addMinutesToTime('6:51',30); console.log(result); result=addMinutesToTime('6:01',30); console.log(result); } </script> </head> <body> </body> </html>