To convert from a Unix timestamp to SQLite's default date format, use the unixepoch
modifier.
To convert a time from UTC to local time, use the localtime
modifier.
To convert from SQLite's default date format to a Unix timestamp, use strftime with the %s
format:
SELECT id,date,name FROM task WHERE strftime('%s', date, 'unixepoch', 'localtime') = ?
It might be easier to use SQLite's built-in method to get the current time, which already is in UTC:
SELECT id,date,name FROM task WHERE datetime('%s', date, 'unixepoch') = datetime('now')
However, if you have only dates, you want to ignore the time portion.
In that case, use date
instead of datetime
:
SELECT id,date,name FROM task WHERE date('%s', date, 'unixepoch') = date('now')