Page 2 of 2

Re: Date of comments

Posted: Mon Jan 23, 2023 10:32 am
by Fabien
If I use the terminal of cPanel and enter the command date, the hour is correct.
But if I run this program :

Code: Select all

<?php
echo date('Y-m-d G:i:s');
?>
the hour is not correct (minus one hour)…

Re: Date of comments

Posted: Mon Jan 23, 2023 5:42 pm
by onli
Interesting! Maybe this is about the timezone not being set in PHP, and cPanel solves this correctly?

Have a look at https://stackoverflow.com/questions/204 ... p-ini-file and https://www.php.net/manual/de/datetime. ... e.timezone please, is the correct timezone set? Alternatively, if you change the code to:

Code: Select all

<?php
 # use your timezone here, see https://www.php.net/manual/de/timezones.php
date_default_timezone_set('America/Los_Angeles');
echo date('Y-m-d G:i:s');
?>
Do you end up with the correct time?

Re: Date of comments

Posted: Tue Jan 24, 2023 7:36 am
by Fabien
Hi Onli,

If I use

Code: Select all

<?php
date_default_timezone_set('Europe/Paris');
echo date('Y-m-d G:i:s');
?>
the date is correctly displayed.

I have looked to the file php.ini. The timezone was not defined and if I enter Europe/Paris the display is now correct.

Best regards.

Re: Date of comments

Posted: Tue Jan 24, 2023 9:16 am
by onli
Awesome :) We could consider adding this as an option to the s9y configuration, but on the other hand, the the PHP configuration can also solve this + the existing offset configuration might be enough. What do you think?

Re: Date of comments

Posted: Tue Jan 24, 2023 10:44 am
by Fabien
Hi Onli,

It seems to me that the ideal would be to be able to specify a timezone in s9y and not have the offset. But is this technically feasible?
If not, I think that the offset is sufficient.

Many many many thanks for your help.
Best regards,
Fabien