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
Syntax
unixepoch(time-value, modifier, ...)
Parameters
| Parameter | Description |
|---|---|
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
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
SELECT datetime(unixepoch('2026-01-01') + 86400, 'unixepoch') AS one_day_later;
Output
one_day_later 2026-01-02 00:00:00
Version history
| Version | Change |
|---|---|
| SQLite 3.38.0 | Added |
In other languages
TO_TIMESTAMP()· PostgreSQL
Related
DATETIME()· Return a date and time as text in YYYY-MM-DD HH:MM:SS form, optionally shifted with modifiers.JULIANDAY()· Return the Julian day number (days since 4714 BC, with a fraction for the time). Subtract two to get days between dates.STRFTIME()· Format a date/time with % codes, such as %Y year, %m month, %d day, %H hour, %W week and %w weekday.- SQL Date Functions · tutorial