Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

display pm or am on date js

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;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: npm ERR! path node_modules/node-sass 
Javascript :: javascript remove space from two side of string 
Javascript :: javascript seconds to min and seconds 
Javascript :: javascript preload images 
Javascript :: string to url javascript 
Javascript :: jquery onclick function 
Javascript :: regex email javascript 
Javascript :: user agent chrome 
Javascript :: react background image 
Javascript :: get input value on keypress jquery 
Javascript :: lerp javascript 
Javascript :: create random hex in node 
Javascript :: display none using jquery 
Javascript :: javascript binary to int 
Javascript :: javascript foreach key value 
Javascript :: loop 
Javascript :: firstElementChild jquery equivalent 
Javascript :: javascript loop through array backward 
Javascript :: converting binary to text js 
Javascript :: has key js 
Javascript :: jquery insert element as first child 
Javascript :: confirm message in jquery 
Javascript :: change window location javascript 
Javascript :: javascript scroll to bottom 
Javascript :: delete cr 
Javascript :: onclick prevent default 
Javascript :: npx create next app 
Javascript :: upload files in react using axios 
Javascript :: byte to gb javascript 
Javascript :: scroll to javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =