Created
September 20, 2018 14:55
-
-
Save yudapc/97c371bf1ffef7d9b474a90215563db4 to your computer and use it in GitHub Desktop.
moment js
This file contains hidden or 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
Cheat moment: | |
http://momentjs.com/ | |
http://momentjs.com/timezone/ | |
moment = require('moment-timezone') | |
get current time AM/PM | |
moment().format('hh:mm A') | |
// 09:54 PM | |
get current time 24 | |
moment().format('HH:mm') | |
// 21:54 | |
get client current timezone: | |
moment.tz.guess(); | |
// Asia/Jakarta | |
iso8601: | |
moment('2018-09-20 08:00 AM').toISOString() | |
// '2018-09-20T01:00:00.000Z' | |
format time from AM/PM to 24: | |
moment('12:00 AM', 'hh:mm A').format('HH:mm') | |
// 00:00 | |
convert time to another timezone: | |
moment('2018-09-20T04:00:00.000Z').tz('Asia/Makassar').format('YYYY-MM-DD HH:mm') | |
// '2018-09-20 12:00' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment