Change default timezone

How could I change the default time zone & date time zone?

inside php.ini

find

date.timezone = "US/Central"
2 Likes

even easier for those struggling for an answer and have no access to either server setup files and/or php.ini and/or do not want to change the entire server or have their dolibarr set up in a sub directory…

GOTO: /DOLIBARR_DIR/conf/ conf.php and insert the following line at the top

in my case:
date_default_timezone_set(‘Europe/London’);

Here is a list of supported timezones.
http://php.net/manual/en/timezones.php

Let me know if it works for you?

Regards :happy:

1 Like

An easier option is Home > Setup >Other Setup

Name: MAIN_SERVER_TZ
Value: America/Toronto
Comment: Corrected TimezonebParameter

5 Likes

Added a reference in the wiki.
Where this kind of information can be found, either?

Yes, that is another easy option and better without editing scripts :happy:

Here is a link to the wiki page containing all the constants
https://wiki.dolibarr.org/index.php/Setup_Other

It should be noted that the constant MAIN_SERVER_TZ is not inserted by setup automatically when first installing the program so you will need to add it via Other Setup.

This page now would have helped a lot when I first set up this ERP/CRM, it was the first page found in my search for a simple answer.

:sunglasses:

@yves57 other constants can be found in Home > Admin tools > About Dolibarr and About PHP or table llx_const. ***To everyone else, modifying most of these other options will break your installation!!.

@globel. I did the same at first but with all our one-off tweaks and not using professional development tools (yet), editing individual files after updates caused too much downtime and work… :happy:

Thank you.
I didn’t know this page :wink:
However, I don’t find the variable MAIN_SERVER_TZ in About Dolibarr nor Abour PHP.
Thus, my question remains, how can I found that this variable is to add.
The indication in Setup Other - Dolibarr ERP CRM Wiki is what I just added.

About Dolibarr and Dolibarr PHP (phpinfo) Info lists what’s set in php.ini or by Dolibarr. In my case, we have a non-production test server on a shared hosting account without easy access to php.ini so I went looking in Dolibarr knowing Setup Other allows some changes to constants in table llx_const.

The actual Dolibarr code I found that were pulling time were in

admin/system/dolibarr.php
https://github.com/Dolibarr/dolibarr/blob/64517d4c0bcbaecef3d1a4e5468b00fae2ecbf0c/htdocs/admin/system/dolibarr.php#L222

and

htdocs/core/class/conf.class.php
https://github.com/Dolibarr/dolibarr/blob/e01d748527f51fe50ea6d247ec59a353fb84f07f/htdocs/core/class/conf.class.php#L220

From there, I just forced the parameter MAIN_SERVER_TZ in Setup Other which Dolibarr is looking for.

Thanks for pointing that.
This is quite old feature, dated March 2014
https://github.com/Dolibarr/dolibarr/commit/24dbfbba60d98ebf10140fef397d7a9996088b42#diff-120e0734b22a44a0f8882b55bdfbb402
Thus, the only way to know that is to explore the code :unhappy:

Yeah agree if you are making a load of changes, but then it may be better to include a separate include file in this case :happy:

This is the only solution that worked on me. TNX