SQLite 3 reference · Date and Time Functions

SQLite UNIXEPOCH() Function

Return a date/time as a Unix timestamp: whole seconds since 1970-01-01 00:00:00 UTC.

SQLite 3 Since 3.38.0

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

unixepoch(time-value, modifier, ...)

Parameters

ParameterDescription
time-value A date/time: 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS', 'now', a Julian day number, or a Unix time with the 'unixepoch' modifier.
modifiers optional Adjustments applied left to right, such as '+1 day', '-3 months', 'start of month', 'weekday 1', 'localtime', 'unixepoch'.

Return value

An integer (a real number with 'subsec'), or NULL.

Examples

Unix timestampsTry it yourself
SELECT unixepoch('2026-01-01') AS start_of_2026,
       unixepoch('2026-01-01 00:01') - unixepoch('2026-01-01') AS seconds;

Output

start_of_2026 | seconds
1767225600 | 60
Round tripTry it yourself
SELECT datetime(unixepoch('2026-01-01') + 86400, 'unixepoch') AS one_day_later;

Output

one_day_later
2026-01-02 00:00:00

Version history

VersionChange
SQLite 3.38.0Added

In other languages

Was this page helpful?