Current Unix Timestamp SECONDS SINCE JAN 01 1970

Current UTC Time
2025-08-20
Convert Datetime to Unix Timestamp in SQLite

How to convert Datetime to Unix timestamp in SQLite

🎈 🎈 🎈
+1

    SELECT strftime('%s', '2024-08-28 12:34:56') AS UnixTimestamp;          
        

Output:
------------------ | UnixTimestamp | ------------------ | 1724848496 |
Example only. There may be multiple ways to perform this operation.

Code Explanation

The strftime() function is used to format date and time values. By using the %s format modifier within strftime(), you can convert a date and time string like '2024-08-28 12:34:56' into a Unix timestamp like '1724848496'.



Other useful SQLite date functions

Function Description Example
date() Returns the date in the format 'YYYY-MM-DD'. Can be used with or without modifiers like 'unixepoch'. date(UnixTimestamp, 'unixepoch') returns 2024-08-28
datetime() Returns the date and time in the format 'YYYY-MM-DD HH:MM:SS'. Can also be used with the 'unixepoch' modifier. datetime(UnixTimestamp, 'unixepoch') returns 2024-08-28 12:34:56
strftime() Formats the date and time according to a specified format string. Can be used with 'unixepoch' to convert Unix timestamps. strftime('%Y-%m-%d %H:%M:%S', UnixTimestamp, 'unixepoch') returns 2024-08-28 12:34:56
julianday() Returns the Julian day number which is the number of days since noon in Greenwich on November 24, 4714 B.C. Can be used with 'unixepoch'. julianday(UnixTimestamp, 'unixepoch') returns 2460150.02315
time() Returns the time in 'HH:MM:SS' format. Useful for extracting time from a timestamp. time(UnixTimestamp, 'unixepoch') returns 12:34:56
current_date Returns the current date as 'YYYY-MM-DD'. current_date returns 2024-08-28
current_time Returns the current time as 'HH:MM:SS'. current_time returns 12:34:56
current_timestamp Returns the current date and time as 'YYYY-MM-DD HH:MM:SS'. current_timestamp returns 2024-08-28 12:34:56
Current Unix Timestamp SECONDS SINCE JAN 01 1970

Current UTC Time
2025-08-20
Ad Banner Placeholder
Ad Banner Placeholder
Ad Banner Placeholder
Ad Banner Placeholder