From: Will Budic Date: Tue, 25 Feb 2020 05:44:06 +0000 (+1100) Subject: Fixed SQL LIte timestamp. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=54b0ec5d12a7f30774846363b5c2a48d299ced50;p=LifeLog.git Fixed SQL LIte timestamp. --- diff --git a/htdocs/cgi-bin/system/modules/Settings.pm b/htdocs/cgi-bin/system/modules/Settings.pm index a6cecb1..d2889ab 100644 --- a/htdocs/cgi-bin/system/modules/Settings.pm +++ b/htdocs/cgi-bin/system/modules/Settings.pm @@ -12,6 +12,7 @@ use Exception::Class ('SettingsException'); use Syntax::Keyword::Try; use DBI; +use DateTime::Format::SQLite; #This is the default developer release key, replace on istallation. As it is not secure. use constant CIPHER_KEY => '95d7a85ba891da'; @@ -287,9 +288,12 @@ sub countRecordsIn { } sub getCurrentSQLTimeStamp { - my $dat = DateTime->now; - $dat -> set_time_zone(timezone()); - return DateTime::Format::SQLite->format_datetime($dat); + + my $dt = DateTime->from_epoch(epoch => time(), time_zone=> $TIME_ZONE); + # 20200225 Found that SQLite->format_datetime, changes internally to UTC timezone, which is wrong. + # Strange that this format_datetime will work from time to time, during day and some dates. (A Pitfall) + #return DateTime::Format::SQLite->format_datetime($dt); + return join ' ', $dt->ymd('-'), $dt->hms(':'); } sub removeOldSessions {