A
A
accountnujen2021-12-18 01:51:33
PHP
accountnujen, 2021-12-18 01:51:33

Why does time (DATETIME DEFAULT CURRENT_TIMESTAMP) have a different value in Sqlite3?

I am creating a table

$sql="CREATE TABLE logs (id INTEGER PRIMARY KEY AUTOINCREMENT, date DATETIME DEFAULT CURRENT_TIMESTAMP, log TEXT)";
$db->query($sql);

only the time in the date field is 3 hours earlier. As I understand it, he lives in a zero time zone, and I live in Moscow, despite the fact that the server is also in Moscow and php returns Moscow time. Tell me, how can I set the correct time zone for sqlite3 in php?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-12-18
@accountnujen

This is how CURRENT_TIMESTAMP works - always in GMT.
Try something likeDEFAULT (datetime('now','localtime'))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question