Format Expression | Output |
---|---|
moment().format("MMMM Do YYYY, h:mm:ss a") | September 22nd 2025, 6:48:56 am |
moment().format("dddd") | Monday |
moment().format("MMM Do YY") | Sep 22nd 25 |
moment().format("YYYY [escaped] YYYY") | 2025 escaped 2025 |
moment().format() | 2025-09-22T06:48:56+00:00 |
Expression | Output |
---|---|
moment("20111031", "YYYYMMDD").fromNow() | 14 years ago |
moment("20120620", "YYYYMMDD").fromNow() | 13 years ago |
moment().startOf('day').fromNow() | 7 hours ago |
moment().endOf('day').fromNow() | in 17 hours |
moment().startOf('hour').fromNow() | an hour ago |
Expression | Output |
---|---|
moment().subtract(10, 'days').calendar() | 09/12/2025 |
moment().subtract(6, 'days').calendar() | Last Tuesday at 6:48 AM |
moment().subtract(3, 'days').calendar() | Last Friday at 6:48 AM |
moment().subtract(1, 'days').calendar() | Yesterday at 6:48 AM |
moment().calendar() | Today at 6:48 AM |
moment().add(1, 'days').calendar() | Tomorrow at 6:48 AM |
moment().add(3, 'days').calendar() | Thursday at 6:48 AM |
moment().add(10, 'days').calendar() | 10/02/2025 |
Expression | Output |
---|---|
moment.locale() | en |
moment().format('LT') | 6:48 AM |
moment().format('LTS') | 6:48:56 AM |
moment().format('L') | 09/22/2025 |
moment().format('l') | 9/22/2025 |
moment().format('LL') | September 22, 2025 |
moment().format('ll') | Sep 22, 2025 |
moment().format('LLL') | September 22, 2025 6:48 AM |
moment().format('lll') | Sep 22, 2025 6:48 AM |
moment().format('LLLL') | Monday, September 22, 2025 6:48 AM |
moment().format('llll') | Mon, Sep 22, 2025 6:48 AM |
Timezone | June 1, 2014 (ha z) | Dec 1, 2014 (ha z) |
---|---|---|
America/Los_Angeles | 5am PDT | 4am PST |
America/New_York | 8am EDT | 7am EST |
Asia/Tokyo | 9pm JST | 9pm JST |
Australia/Sydney | 10pm AEST | 11pm AEDT |
Expression | Output |
---|---|
moment.tz("2014-06-01 12:00", "America/New_York") | 2014-06-01T12:00:00-04:00 |
moment.tz("2014-06-01 12:00", "America/Los_Angeles") | 2014-06-01T09:00:00-07:00 |
moment.tz("2014-06-01 12:00", "Europe/London") | 2014-06-01T17:00:00+01:00 |
Welcome to Fast 2kB alternative to Moment.js with the same modern API
Format Expression | Output |
---|---|
dayjs().format("MMMM D YYYY, h:mm:ss A") | September 22 2025, 6:48:56 AM |
dayjs().format("dddd") | Monday |
dayjs().format("MMM D YY") | Sep 22 25 |
dayjs().format("YYYY [escaped] YYYY") | 2025 escaped 2025 |
dayjs().format() | 2025-09-22T06:48:56+00:00 |
Expression | Output |
---|---|
dayjs("20111031", "YYYYMMDD").fromNow() | 14 years ago |
dayjs("20120620", "YYYYMMDD").fromNow() | 13 years ago |
dayjs().startOf('day').fromNow() | 7 hours ago |
dayjs().endOf('day').fromNow() | in 17 hours |
dayjs().startOf('hour').fromNow() | an hour ago |
Format Expression | Output |
---|---|
dayjs().format("MMMM D YYYY, h:mm:ss A") | September 22 2025, 6:48:56 AM |
dayjs().format("dddd") | Monday |
dayjs().format("MMM D YY") | Sep 22 25 |
dayjs().format("YYYY [escaped] YYYY") | 2025 escaped 2025 |
dayjs().format() | 2025-09-22T06:48:56+00:00 |
today.calendar() | Today at 6:48 AM |
tomorrow.calendar() | Tomorrow at 6:48 AM |
today.calendar() | 9/22/2025 |
Expression | Output |
---|---|
dayjs.locale() | en |
dayjs().format('LT') | 6:48 AM |
dayjs().format('LTS') | 6:48:56 AM |
dayjs().format('L') | 09/22/2025 |
dayjs().format('l') | 9/22/2025 |
dayjs().format('LL') | September 22, 2025 |
dayjs().format('ll') | Sep 22, 2025 |
dayjs().format('LLL') | September 22, 2025 6:48 AM |
dayjs().format('lll') | Sep 22, 2025 6:48 AM |
dayjs().format('LLLL') | Monday, September 22, 2025 6:48 AM |
dayjs().format('llll') | Mon, Sep 22, 2025 6:48 AM |
Timezone | June 1, 2014 (ha z) | Dec 1, 2014 (ha z) |
---|---|---|
America/Los_Angeles | 5AM PDT | 4AM PST |
America/New_York | 8AM EDT | 7AM EST |
Asia/Tokyo | 9PM GMT+9 | 9PM GMT+9 |
Australia/Sydney | 10PM GMT+10 | 11PM GMT+11 |
Timezone | Formatted Output |
---|---|
dayjs.tz(baseTime, "America/New_York") | 2014-06-01T12:00:00-04:00 |
dayjs.tz(baseTime, "America/Los_Angeles") | 2014-06-01T09:00:00-07:00 |
dayjs.tz(baseTime, "Europe/London") | 2014-06-01T17:00:00+01:00 |
Perbandingan antara dua library populer untuk manipulasi tanggal dan waktu di JavaScript: Moment.js dan Day.js.
Fitur | Moment.js | Day.js |
---|---|---|
Tahun Dirilis | 2011 | 2018 |
Ukuran Bundle | ~67 KB | ~2 KB |
Performa | Relatif lambat | Cepat dan ringan |
Tree-shaking | β Tidak mendukung | β Mendukung |
Status Proyek | Legacy | Aktif |
π Bundle size Day.js: bundlephobia.com/package/dayjs
π Bundle size Moment.js: bundlephobia.com/package/moment