SQLite Forum

Bug ? Same query that works in shell produces constraint violation when run by a C program with sqlite3_{prepare,bind,step}
Thanks Keith -

I am getting the ISO-8601 timestamp string from an external networked server, which is relaying them from many hosts which may be in different timezones - so I want to store the timestamps in UTC, and so am applying the offset to express the time in UTC.

When it works, this is what strftime( '%s', $X, 'utc') does - it converts the timestamp to a UNIX epoch second, and then, IFF the string specifies a UTC offset, and not 'Z', it adds / subtracts the offset converted to seconds to the epoch seconds value.

In the shell:

sqlite> select strftime('%s', '2021-03-21T18:00:00+00:00', 'utc'); 1616349600 

sqlite> select strftime('%s', '2021-03-21T18:00:00+01:00', 'utc'); 1616346000