31,016
edits
| Line 265: | Line 265: | ||
== Dates and Timezones == | == Dates and Timezones == | ||
Dolibarr | Dolibarr is an application that is multi-user and multi-location. It's therefore necessary to store dates in the right format. To avoid problems with conversions, the following rules should be applied: | ||
* | * A date into memory must always be stored with Timestamp GMT format. | ||
* | * A date stored into database, is the GMT Timestamp of date submitted into the request usng the <b>PHP server</b> timezone. This does not apply to date update automatically by database (fields '''tms''' into database). | ||
For exemple le 1st january 1970, 3 hour at Paris (TZ=+1) = 2 hour at Greenwitch (TZ=0) will be stored into memory with value 7200 and will be submitted into a SQL request to database with the string '19700101030000' (PHP convert into its TZ hour and databse will unconvert it using its timezone too that is same than PHP). | |||
All select methods should translate date fields, that are with format TZ of database ('19700101030000'), into a timestamp field by calling the method db->jdate. This is to store into memory a GTM Timestamp date. All insert methods must convert, during generation of SQL request, the memory date into the string by using db->idate (you may find examples into skeleton). | |||
* | * Dates that are update automatically (field '''tms''' into database) contains a GMT Timestamp GMT of date when change is done. | ||
== UTF8/ISO encoding == | == UTF8/ISO encoding == | ||