SQLite Tutorial
|
|
|
|
| Articles Reviews Structured Query Language | |
| Written by Mike Chirico | |
| Monday, 27 November 2006 | |
|
Page 3 of 12 UTC and Localtime sqlite> select datetime('now'); There is an advantage to inserting UTC time like we did with the triggers above, since UTC can easily be converted to localtime after UTC has been entered in the table. See the command below. By inserting UTC, you avoid problems when working with multiple databases that may not share the same timezone and/or dst settings. By starting with UTC, you can always obtain the localtime. (Reference: Working with Time) CONVERTING TO LOCALTIME:
sqlite> select datetime('now','localtime','+3.5 seconds','+10 minutes'); It is also possible to get the weekday where 0 = Sunday, 1 = Monday, 2 = Tuesday ... 6 = Saturday. sqlite> select datetime('now','localtime','+3.5 seconds','weekday 2'); The complete list of options, or modifiers as they are called in this file, are as follows:
In addition, there is the "strftime" function, which will take a timestring, and convert it to the specified format, with the modifications. Here is the format for this function: ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) Below is an example.
|
|
| Last Updated ( Sunday, 06 January 2008 ) | |
| < Prev | Next > |
|---|







