• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

UTC time as same Europe/Berlin in PHP

R

RogerSik

Guest
Hello,

in the shell the time is displayed right. See:

Code:
# timedatectl
Local time: Wed 2018-03-21 14:45:41 CET
Universal time: Wed 2018-03-21 13:45:41 UTC
RTC time: Wed 2018-03-21 13:45:41
Time zone: Europe/Berlin (CET, +0100)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no

But in PHP its always the UTC Time.

Example PHP script output:
Code:
object(DateTime)#1 (3) { ["date"]=> string(26) "2018-03-21 14:44:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Berlin" } object(DateTime)#1 (3) { ["date"]=> string(26) "2018-03-21 14:44:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }

Why is this happening? How can this be fixed?
 
I do not see an issue here. The "local time" is what the timezone is co-definining. UTC is 13.45, Berlin is 1h ahead of UTC so the local time is 14.45.
 
Yes the timedatectl shows it right but not the PHP Scripts.

Example WordPress:
UTC is 22.03.2018 10:42:52.
Local Time is 22.03.2018 11:42:52.

This result was created at 10:42 local time.

Or the php script above. Where both timezones has the same time (see bolded).

object(DateTime)#1 (3) { ["date"]=> string(26) "2018-03-21 14:44:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/Berlin" } object(DateTime)#1 (3) { ["date"]=> string(26) "2018-03-21 14:44:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }
 
Your claim seems to be that the DateTime object in PHP should read the timezone that is set by its own setTimezone method and then automatically convert a time given to the timezone that is set by the method. But that is not what it does. It is an object that can handle datetime data, and it stores information that you want it to store. It does not automatically convert anything. You could set any time and timezone, and the object will return the setting.

To test whether PHP uses the correct time, you can use getdate() instead.
 
Back
Top