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

Time from now ​

Returns the string of relative time from now.

TIP

This requires the RelativeTime plugin to work

js
dayjs.extend(relativeTime);

dayjs('1999-01-01').fromNow(); // 22 years ago

If you pass true, you can get the value without the suffix.

js
dayjs.extend(relativeTime);

dayjs('1999-01-01').fromNow(true); // 22 years

List of breakdown range ​

The base strings are localized by the current locale and can be customized. Time is rounded to the nearest second.

RangeKeySample Output
0 to 44 secondssa few seconds ago
45 to 89 secondsma minute ago
90 seconds to 44 minutesmm2 minutes ago ... 44 minutes ago
45 to 89 minuteshan hour ago
90 minutes to 21 hourshh2 hours ago ... 21 hours ago
22 to 35 hoursda day ago
36 hours to 25 daysdd2 days ago ... 25 days ago
26 to 45 daysMa month ago
46 days to 10 monthsMM2 months ago ... 10 months ago
11 months to 17monthsya year ago
18 months+yy2 years ago ... 20 years ago
Pager
Previous pageFormat
Next pageTime from X

Released under the MIT License.

Copyright (c) 2020 iamkun

https://day.js.org/docs/en/display/from-now

Released under the MIT License.

Copyright (c) 2020 iamkun