Created
November 10, 2016 06:36
-
-
Save ZaneHannanAU/19b83925836b420aa86e35fe7f8b2f9b to your computer and use it in GitHub Desktop.
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
// Server side NodeJS. | |
var dateFormat = module.exports = {} | |
dateFormat.opts = { | |
day: 'numeric', | |
hour: 'numeric', | |
minute: 'numeric', | |
month: 'long', | |
weekday: 'long', | |
year: 'numeric', | |
timeZoneName: 'long' | |
} | |
dateFormat.format = function(date, locale) { | |
return new Date(date).toLocaleDateString( | |
({}||locale), | |
dateFormat.opts | |
) | |
} | |
dateFormat.atNow = function(locale) { | |
return dateFormat.format( | |
Date.now(), | |
locale | |
) | |
} | |
dateFormat.numeric = function(date) { | |
return new Date(date).valueOf; | |
} | |
dateFormat.UTC = function(date) { | |
return new Date(date||Date.now()).toISOString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment