How to determine the time zone for a specific date-time in a specific place?

I have dates of events in another country that I need to save in a database. The problem is that these dates do not contain time zone information.

The time zone used at this location is CET (standard time) or CEST (summer time).

What is the easiest way to determine which one is in the game?

+6
source share
2 answers

I'm not quite sure what you are asking. I think you need to find out if a specific date is for summer savings or not. If so, you can use date('I') .

 $dst_now = date('I'); // whether our current timezone is currently in DST $dst_then = date('I', strtotime($date)); // whether that date is in DST for our current timezone $date_obj = new DateTime($date, new DateTimeZone('Europe/Paris')); $dst_thereandthen = $date_obj->format('I'); // whether that date is in DST for that timezone 

If you do not need any of them, please specify what you need ...

+3
source

I would suggest that the date_default_timezone_get () function will provide you with the necessary information, although I'm not quite sure that it can distinguish between standard / summer time.

date_default_timezone_get ()

+1
source

Source: https://habr.com/ru/post/904346/


All Articles