JS tips and tricks
		
		
		
		Jump to navigation
		Jump to search
		
Display JavaScript datetime in 12 hour AM/PM format[1]
toLocaleTimeString() may behave differently based on region / location
var time = new Date();
console.log(
  time.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true })
);
toLocaleTimeString() may behave differently based on region / location