I have already read How to get local time in php? and similar questions, but here I want to do the contrary: With a given datetime in UTC (e.g. 2021-03-31 23:45:00), how to output the date in local …
Tag: utc
Weird behavior PHP DateTime and DateTimeZone
PHP DateTime and DateTimeZone works incorrectly for me around DST change dates. I wrote a simple function to convert local time to UTC and I called it with the midnight time from the 24th of Oct to the 2nd of Nov with the timezones Europe/Paris and CET: The output: For Europe/Paris I got the changed DST instead of the 31st
Using time zones in a PHP web application
I’ve been looking around for a few hours now about what’s the best way to use timezones in a PHP/MySQL web application, finding a definitive answer is hard. From what I’ve learnt so far it is best to store everyones stuff in the database in UTC (correct me if I am wrong). When a user registers I will ask them
PHP UTC to Local Time
Server Environment Redhat Enterprise Linux PHP 5.3.5 Problem Let’s say I have a UTC date and time such as 2011-04-27 02:45 and I want to convert it to my local time, which is America/New_York. Three questions: 1.) My code below might solve the problem, would you agree? 2.) But, does the value of $offset automatically adjust for Daylight Savings Time