Day.js

Day.js

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

›Durations

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

Humanize

Sometimes, you want all the goodness of dayjs#from but you don't want to have to create two Day.js objects, you just want to display a length of time.

This requires the Duration plugin to work

This requires the RelativeTime plugin to work

dayjs.extend(duration)
dayjs.extend(relativeTime)
dayjs.duration(1, "minutes").humanize(); // a minute
dayjs.duration(2, "minutes").humanize(); // 2 minutes
dayjs.duration(24, "hours").humanize();  // a day

By default, the return string is suffixless. If you want a suffix, pass in true as seen below.

dayjs.duration(1, "minutes").humanize(true); // in a minute

For suffixes before now, pass in a negative number.

dayjs.duration(-1, "minutes").humanize(true); // a minute ago
← CloneFormat →
Day.js
Community
GitHubGitterSitemap
Copyright © 2025 Day.js