Date of comments

Found a bug? Tell us!!
Fabien
Regular
Posts: 204
Joined: Wed Mar 15, 2006 1:02 pm
Location: Paris (France)
Contact:

Re: Date of comments

Post 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)…
Fabien Chabreuil (blog)
onli
Regular
Posts: 2730
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Date of comments

Post 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?
Fabien
Regular
Posts: 204
Joined: Wed Mar 15, 2006 1:02 pm
Location: Paris (France)
Contact:

Re: Date of comments

Post 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.
Last edited by Fabien on Tue Jan 24, 2023 10:40 am, edited 1 time in total.
Fabien Chabreuil (blog)
onli
Regular
Posts: 2730
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Date of comments

Post 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?
Fabien
Regular
Posts: 204
Joined: Wed Mar 15, 2006 1:02 pm
Location: Paris (France)
Contact:

Re: Date of comments

Post 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
Fabien Chabreuil (blog)
Post Reply