Created
May 29, 2020 09:53
-
-
Save Farmatique/64cf13e9a1474dc1b75a9058833659fd to your computer and use it in GitHub Desktop.
Date Am/Pm format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//from here: https://stackoverflow.com/a/8888498/6775194 | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment