I have this JavaScript
let dateTime = new Date().toISOString()
console.log(dateTime)
// 2024-05-01T11:55:51.602Z
And this SQLite
SELECT strftime('%Y-%m-%dT%H:%M:%S.%fZ', 'now');
-- 2024-05-01T11:53:47.47.812Z
If I try to parse the above
let dateTime = new Date("2024-05-01T11:53:47.47.812Z")
console.log(dateTime)
// Invalid Date
How do I get the result to be identical to the JS “toISOString” in SQLite?
Here are the articles I’ve read, I’m sure I’m missing something small, but I just can’t figure it out
- https://www.sqlite.org/lang_datefunc.html (no example for ISO 8601
with timestamp) - https://www.internotes.net/sqlite-dates (has ISO example but no
timestamp) - Select Sqlite date values in ISO 8601 format
(no sqlite answer)