Default timezone set

Dear,

I need your help and assist, my database in phpmyadmin time is not right.
The time is 6 hours in minus. I am from EU Republic of Croatia.
I try date_default_timezone_set(‘Europe/Zagreb’); in my php code and change in Alter PHP Config menu in the control panel, but nothing change still the time is 6+ hours :frowning: in phpmyadmin I set to DATETIME.

Thanks in advance
Kind Regards

You can set the time zone for PHP using either of the methods you tried. However, note that those only set the timezone for PHP on that specific website.

Setting the PHP timezone doesn’t change the database timezone. The database timezone is governed by the system time of the database server. This time cannot be set for individual databases or users.

So when working with time, make sure to always use the web server time from PHP. Don’t use the time from the database server using functions like NOW() in the query. Instead, generate specific timestamps from your PHP code.

ScreenHunter 60
Dear Admin,

I want to show users the time from database :confused:
You say this is not possible to change, even with the php code on my website?
Simply just want to show members the registration date “24.02.2021 01:32” but the time is always -6 h what is the real time on the server, I understand that!
Do I have some option?

Thanks in advance


this is the time from database when usermember registered, it is possible to change that time with php code?

Yes. You can do what I told you to do in my previous message:

I don’t know what you’re doing exactly in your site, but if your times are off, then you’re not doing what I told you to do.

So just generate the registration date in PHP and store it in the database. The database server time doesn’t matter unless you you let the database generate dates for you. Which you shouldn’t do - you should do that through PHP code.

If you don’t understand what I mean, or you say you already did this, can you please share the following:

  • How and where did you set the timezone for PHP.
  • A code snippet showing how you store the registration date in the database.
  • A code snippet showing how you retrieve and show the registration date from the database.
1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.