js get time in am
var time = new Date();
console.log(
time.toLocaleString('en-US', { hour: 'numeric', hour12: true })
); function formatAMPM(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
return strTime;
}
console.log(formatAMPM(new Date));
Also in JavaScript:
- react hooks call child fuynction
- deep clone javascript object
- Ajax send date to MVC
- jquery accordion
- uncheck checkbox when another is checked javascript
- find an object from array of objects javascript
- Rectangle class module
- check for balanced parentheses in javascript
- remove element from javascript array
- break loop after time javascript
- switch case mdn
- looping in javascript
- stackable in amcharts 3
- $() jquery document
- tutorial of machine learning js
- The expression cannot be a selector (occur after a dot)
- laravel send http post request json
- html select specify deafult select by js variable
- how sent data to dilaog angular material
- javascript on scroll change nav color
- let in javascript
- discord bot javascript remove user data in array
- load a script after a button is pressed js
- string interpolation