Skip to content
Day.js

English

简体中文
繁體中文
Español
Français
Русский
Português – Brasil
Deutsch
日本語
한국어
Italiano
Polski
Türkçe
čeština
magyar

English

简体中文
繁體中文
Español
Français
Русский
Português – Brasil
Deutsch
日本語
한국어
Italiano
Polski
Türkçe
čeština
magyar

Appearance

Sidebar Navigation

Installation

Node.js

Browser

TypeScript

Download

Parse

Now

String

String + Format

Unix Timestamp (milliseconds)

Unix Timestamp (seconds)

Date

Object

Array

UTC

Dayjs Clone

Validation

Get + Set

Millisecond

Second

Minute

Hour

Date of Month

Day of Week

Day of Week (Locale Aware)

ISO Day of Week

Day of Year

Week of Year

Week of Year (ISO)

Month

Quarter

Year

Week Year

Week Year (ISO)

Weeks In Year (ISO)

Get

Set

Maximum

Minimum

Manipulate

Add

Subtract

Start of Time

End of Time

Local

UTC

UTC offset

Display

Format

Time from now

Time from X

Time to now

Time to X

Calendar Time

Difference

Unix Timestamp (milliseconds)

Unix Timestamp

Days in Month

As Javascript Date

As Array

As JSON

As ISO 8601 String

As Object

As String

Query

Is Before

Is Same

Is After

Is Same or Before

Is Same or After

Is Between

Is a Dayjs

Is Leap Year

i18n

Loading locale in NodeJS

Loading locale in the browser

Changing locale globally

Changing locales locally

Checking the current Day.js locale

Listing the months and weekdays of the current locale

Accessing locale specific functionality

Plugins

Loading plugin in NodeJS

Loading plugin in the browser

AdvancedFormat

ArraySupport

BadMutable

BigIntSupport

BuddhistEra

Calendar

CustomParseFormat

DayOfYear

DevHelper

Duration

IsBetween

IsLeapYear

IsSameOrAfter

IsSameOrBefore

IsToday

IsTomorrow

IsYesterday

IsoWeek

IsoWeeksInYear

LocaleData

LocalizedFormat

MinMax

ObjectSupport

PluralGetSet

PreParsePostFormat

QuarterOfYear

RelativeTime

Timezone

ToArray

ToObject

UpdateLocale

UTC

weekOfYear

WeekYear

Weekday

Customize

Month Names

Month Abbreviations

Weekday Names

Weekday Abbreviations

Minimal Weekday Abbreviations

Relative Time

Calendar

Durations

Creating

Clone

Humanize

Format

Milliseconds

Seconds

Minutes

Hours

Days

Weeks

Months

Years

Add Time

Subtract Time

Using Duration with Diff

As Unit of Time

Get Unit of Time

As JSON

Is a Duration

As ISO 8601 String

Locale

Time Zone

Parsing in Zone

Converting to Zone

Guessing user zone

Set Default Timezone

On this page

AdvancedFormat ​

AdvancedFormat extends dayjs().format API to supply more format options.

javascript
var advancedFormat = require('dayjs/plugin/advancedFormat');
// import advancedFormat from 'dayjs/plugin/advancedFormat' // ES 2015

dayjs.extend(advancedFormat);

dayjs().format('Q Do k kk X x');

Note: some of the format options like z and zzz in the table below require additional plugins.

List of added formats:

FormatOutputDescription
Q1-4Quarter
Do1st 2nd ... 31stDay of Month with ordinal
k1-24The hour, beginning at 1
kk01-24The hour, 2-digits, beginning at 1
X1360013296Unix Timestamp in second
x1360013296123Unix Timestamp in millisecond
w1 2 ... 52 53Week of year ( dependent WeekOfYear plugin )
ww01 02 ... 52 53Week of year, 2-digits ( dependent WeekOfYear plugin )
W1 2 ... 52 53ISO Week of year ( dependent IsoWeek plugin )
WW01 02 ... 52 53ISO Week of year, 2-digits ( dependent IsoWeek plugin )
wo1st 2nd ... 52nd 53rdWeek of year with ordinal ( dependent WeekOfYear plugin )
gggg2017Week Year ( dependent WeekYear plugin )
GGGG2017ISO Week Year ( dependent IsoWeek plugin )
zESTAbbreviated named offset ( dependent Timezone plugin )
zzzEastern Standard TimeUnabbreviated named offset ( dependent Timezone plugin )
Pager
Previous pageLoading plugin in the browser
Next pageArraySupport

Released under the MIT License.

Copyright (c) 2020 iamkun

https://day.js.org/docs/en/plugin/advanced-format

Released under the MIT License.

Copyright (c) 2020 iamkun