Day.js

Day.js

  • Docs
  • GitHub
  • Languages iconEnglish
    • 中文
    • Русский
    • Español
    • Help Translate

›Plugins

Installation

  • Installation
  • Node.js
  • Browser
  • TypeScript
  • Download

Parse

  • Parse
  • Now
  • String
  • String + Format
  • Unix Timestamp (milliseconds)
  • Unix Timestamp (seconds)
  • Date
  • Object
  • Array
  • UTC
  • Dayjs Clone
  • Validation

Get + Set

  • 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

  • Manipulate
  • Add
  • Subtract
  • Start of Time
  • End of Time
  • Local
  • UTC
  • UTC offset

Display

  • 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

  • Query
  • Is Before
  • Is Same
  • Is After
  • Is Same or Before
  • Is Same or After
  • Is Between
  • Is a Dayjs
  • Is Leap Year

i18n

  • 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

  • Plugin
  • 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

  • Customize
  • Month Names
  • Month Abbreviations
  • Weekday Names
  • Weekday Abbreviations
  • Minimal Weekday Abbreviations
  • Relative Time
  • Calendar

Durations

  • 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

  • Time Zone
  • Parsing in Zone
  • Converting to Zone
  • Guessing user zone
  • Set Default Timezone
Edit

UTC

UTC adds .utc .local .isUTC APIs to parse or display in UTC.

var utc = require("dayjs/plugin/utc");
// import utc from 'dayjs/plugin/utc' // ES 2015

dayjs.extend(utc);

// default local time
dayjs().format(); //2019-03-06T17:11:55+08:00

// UTC mode
dayjs.utc().format(); // 2019-03-06T09:11:55Z

// convert local time to UTC time
dayjs().utc().format(); // 2019-03-06T09:11:55Z

// While in UTC mode, all display methods will display in UTC time instead of local time.
// And all getters and setters will internally use the Date#getUTC* and Date#setUTC* methods instead of the Date#get* and Date#set* methods.
dayjs.utc().isUTC(); // true
dayjs.utc().local().format(); //2019-03-06T17:11:55+08:00
dayjs.utc("2018-01-01", "YYYY-MM-DD"); // with CustomParseFormat plugin

By default, Day.js parses and displays in local time.

If you want to parse or display in UTC, you can use dayjs.utc() instead of dayjs().

dayjs.utc dayjs.utc(dateType?: string | number | Date | Dayjs, format? string)

Returns a Dayjs object in UTC mode.

Use UTC time .utc()

Returns a cloned Dayjs object with a flag to use UTC time.

Use local time .local()

Returns a cloned Dayjs object with a flag to use local time.

Set UTC offset .utcOffset()

Returns a cloned Dayjs object with a new UTC offset.

isUTC mode .isUTC()

Returns a boolean indicating current Dayjs object is in UTC mode or not.

← UpdateLocaleweekOfYear →
Day.js
Community
GitHubGitterSitemap
Copyright © 2025 Day.js