Kinda' depend on what exactly you want to do.
If you want your application to always use local time no matter where it's run:
select('now','localtime');
If you want to know how far off of UTC you are do this:
select round((julianday('now','localtime')-julianday('now'))*24);
In my case this returns -5 for Central Daylight Time.
If your case you should 2 hours.
If the time has any meaning across timezones where your applicaiton is run you
should stick with UTC and perhaps just display local time to the users.
sqlite> select datetime('now');
2012-06-27 16:14:46
sqlite> create table t(mydate);
sqlite> insert into t values(datetime('now'));
sqlite> select datetime(mydate,'localtime') from t;
2012-06-27 11:17:13
Michael D. Black
Senior Scientist
Advanced Analytics Directorate
Advanced GEOINT Solutions Operating Unit
Northrop Grumman Information Systems
From: [email protected] [[email protected]] on
behalf of [email protected] [[email protected]]
Sent: Wednesday, June 27, 2012 10:45 AM
To: [email protected]; General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] sqlite time is 2 hours to late
Am 27.06.2012 17:40, schrieb Jay A. Kreibich:
>
> On Wed, Jun 27, 2012 at 05:37:55PM +0200, [email protected] scratched on
> the wall:
>
>> Hello,
>>
>>> sqlite3 event.db "select datetime('now')";
>> gives me a time that is 2 hours too late ( 2012-06-27 15:33:13)
>> than my system time ( win 7 ) 17::33:13
>>
>> How can this be fixed ?
> Move two timezones to the west.
>
> (By default all times and dates are UTC.)
>
> -j
>
>
I use this from within a c++ application
char create_sql[] = "CREATE TABLE if not exists eventlog ("
"id INTEGER PRIMARY KEY,"
"eventdate DATETIME default current_timestamp,"
"eventtype TEXT,"
")";
How do I get the right time in the the column eventdate ?
How to move timezones ?
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users