Dates
date(...) wraps a moment in time, dayjs-style: create one, chain arithmetic, finish with format
or timeAgo. Both understand English and Russian and default to the current device language
(device.language) when you don't pass one. Formatting is pure JS — no Intl — so
output is identical on every platform.
date(value?: Date | number | string | DateValue): DateValueThe argument may be a Date, a millisecond timestamp (Date.now()), a parseable string, or another
DateValue; with no argument it's the current time.
date().format('dddd, D MMMM') // "Friday, 10 July" · "пятница, 10 июля"
date(ts).format('DD.MM.YYYY HH:mm') // "10.07.2026 14:05"
date(ts).timeAgo() // "5 minutes ago" · "5 минут назад"The returned DateValue is immutable — every method returns a new value, so it's safe to hold
and reuse. It also coerces to its epoch-ms via valueOf(), so +date(x), date(a) - date(b), and
date(a) < date(b) all just work.
Formatting — .format
.format(pattern = 'D MMMM YYYY', locale?: 'en' | 'ru'): stringFormat against a day.js-style token pattern (default: a long date).
YYYY YY |
year | 2026, 26 |
MMMM MMM MM M |
month | July, Jul, 07, 7 |
DD D |
day of month | 05, 5 |
dddd ddd |
weekday | Friday, Fri |
HH H |
hour (24) | 08, 8 |
hh h |
hour (12) | 08, 8 |
mm m |
minute | 05, 5 |
ss s |
second | 09, 9 |
A a |
AM/PM | PM, pm |
Non-token characters (spaces, ., :, ,) are copied through verbatim.
Russian month case. Russian writes the month differently by context: genitive with a day (
10 июля), nominative on its own (Июль 2026)..formatpicks the right one automatically by whether the pattern contains a day (D) token.
Relative time — .timeAgo
.timeAgo(locale?: 'en' | 'ru', now?: Date | number | DateValue): stringHuman relative time vs now (default: the current time). Picks the largest fitting unit, reads as
"just now" / "только что" under ~45 seconds, and handles Russian number agreement
(1 минуту / 2 минуты / 5 минут).
date(ts).timeAgo() // "5 minutes ago" · "5 минут назад"
date(future).timeAgo() // "in 2 days" · "через 2 дня"Arithmetic — chainable, immutable
.add(n, unit) .subtract(n, unit) // unit: 'ms'|'second'|'minute'|'hour'|'day'|'week'|'month'|'year'
.startOf(unit) .endOf(unit) // snap to start/end of the unit (local time)date().add(3, 'day').startOf('day').format('D MMMM') // "13 July"
date(ts).endOf('month').format('D MMMM') // "31 July"month/year are calendar-aware and clamp on short months (Jan 31 + 1 month → Feb 28), matching
day.js.
Comparison & extraction — scalars
.diff(other, unit = 'ms'): number // signed whole units, truncated toward zero
.isBefore(other) .isAfter(other) .isSame(other): boolean
.valueOf(): number // epoch ms .unix(): number // epoch seconds
.year() .month() .day() .weekday() .hour() .minute() .second(): number
.toDate(): Datedate(a).diff(b, 'hour') // e.g. -3
date(a).isBefore(b) // true.month() is 0-based and .weekday() is 0 (Sunday)–6, both matching the native Date getters.
See also
- device —
device.language, the default locale source