| Format Expression | Output |
|---|---|
moment().format("MMMM Do YYYY, h:mm:ss a") | February 4th 2026, 8:49:38 pm |
moment().format("dddd") | Wednesday |
moment().format("MMM Do YY") | Feb 4th 26 |
moment().format("YYYY [escaped] YYYY") | 2026 escaped 2026 |
moment().format() | 2026-02-04T20:49:38+00:00 |
| Expression | Output |
|---|---|
moment("20111031", "YYYYMMDD").fromNow() | 14 years ago |
moment("20120620", "YYYYMMDD").fromNow() | 14 years ago |
moment().startOf('day').fromNow() | 21 hours ago |
moment().endOf('day').fromNow() | in 3 hours |
moment().startOf('hour').fromNow() | an hour ago |
| Expression | Output |
|---|---|
moment().subtract(10, 'days').calendar() | 01/25/2026 |
moment().subtract(6, 'days').calendar() | Last Thursday at 8:49 PM |
moment().subtract(3, 'days').calendar() | Last Sunday at 8:49 PM |
moment().subtract(1, 'days').calendar() | Yesterday at 8:49 PM |
moment().calendar() | Today at 8:49 PM |
moment().add(1, 'days').calendar() | Tomorrow at 8:49 PM |
moment().add(3, 'days').calendar() | Saturday at 8:49 PM |
moment().add(10, 'days').calendar() | 02/14/2026 |
| Expression | Output |
|---|---|
moment.locale() | en |
moment().format('LT') | 8:49 PM |
moment().format('LTS') | 8:49:38 PM |
moment().format('L') | 02/04/2026 |
moment().format('l') | 2/4/2026 |
moment().format('LL') | February 4, 2026 |
moment().format('ll') | Feb 4, 2026 |
moment().format('LLL') | February 4, 2026 8:49 PM |
moment().format('lll') | Feb 4, 2026 8:49 PM |
moment().format('LLLL') | Wednesday, February 4, 2026 8:49 PM |
moment().format('llll') | Wed, Feb 4, 2026 8:49 PM |
| 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") | February 4 2026, 8:49:38 PM |
dayjs().format("dddd") | Wednesday |
dayjs().format("MMM D YY") | Feb 4 26 |
dayjs().format("YYYY [escaped] YYYY") | 2026 escaped 2026 |
dayjs().format() | 2026-02-04T20:49:38+00:00 |
| Expression | Output |
|---|---|
dayjs("20111031", "YYYYMMDD").fromNow() | 14 years ago |
dayjs("20120620", "YYYYMMDD").fromNow() | 14 years ago |
dayjs().startOf('day').fromNow() | 21 hours ago |
dayjs().endOf('day').fromNow() | in 3 hours |
dayjs().startOf('hour').fromNow() | an hour ago |
| Format Expression | Output |
|---|---|
dayjs().format("MMMM D YYYY, h:mm:ss A") | February 4 2026, 8:49:38 PM |
dayjs().format("dddd") | Wednesday |
dayjs().format("MMM D YY") | Feb 4 26 |
dayjs().format("YYYY [escaped] YYYY") | 2026 escaped 2026 |
dayjs().format() | 2026-02-04T20:49:38+00:00 |
today.calendar() | Today at 8:49 PM |
tomorrow.calendar() | Tomorrow at 8:49 PM |
today.calendar() | 2/4/2026 |
| Expression | Output |
|---|---|
dayjs.locale() | en |
dayjs().format('LT') | 8:49 PM |
dayjs().format('LTS') | 8:49:38 PM |
dayjs().format('L') | 02/04/2026 |
dayjs().format('l') | 2/4/2026 |
dayjs().format('LL') | February 4, 2026 |
dayjs().format('ll') | Feb 4, 2026 |
dayjs().format('LLL') | February 4, 2026 8:49 PM |
dayjs().format('lll') | Feb 4, 2026 8:49 PM |
dayjs().format('LLLL') | Wednesday, February 4, 2026 8:49 PM |
dayjs().format('llll') | Wed, Feb 4, 2026 8:49 PM |
| 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