Skip to content

Tutorial: dates and times ​

The official date plugin adds {@date} and {@datetime} directives.

Basic date ​

html
{@date}

The default format is:

text
YYYY-MM-DD

Basic datetime ​

html
{@datetime}

The default format is:

text
YYYY-MM-DD HH:mm:ss

Custom formats ​

Use as:

html
{@date as DD.MM.YYYY}
{@datetime as HH:mm:ss}
{@datetime as DD.MM.YYYY HH:mm}

Format tokens ​

TokenMeaning
YYYYFour-digit year
YYTwo-digit year
MMMMFull month name
MMMShort month name
MM / MMonth
DD / DDay
ddddFull weekday
dddShort weekday
HH / H24-hour clock
hh / h12-hour clock
mm / mMinutes
ss / sSeconds
SSSMilliseconds
AAM/PM
aam/pm
ZTimezone offset, e.g. +02:00
ZZCompact timezone offset, e.g. +0200

Separators are preserved.

Specific dates ​

html
{@date "2026-09-26" as DD.MM.YYYY}
{@datetime "2026-09-26T14:05:09" as HH:mm:ss}

Use now explicitly:

html
{@datetime now as HH:mm:ss}

Locale and timezone ​

Month and weekday names use the runtime locale. Date and time fields use the JavaScript runtime's local timezone.

Direct API ​

The plugin also exports formatDate:

js
import { formatDate } from "@rebase/date";

formatDate(new Date(2026, 8, 26), "DD.MM.YYYY");

This is useful outside Rebase templates.

Made by the Rebase Team