9951 explained code solutions for 126 technologies


javascriptFormat date in HH:II (hours:minutes)


var d = new Date();
var formatted = ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2);ctrl + c
var d = new Date()

create date object

d.getHours()

returns current hour

d.getMinutes()

returns current minute

formatted

this variable will contain formatted date string