I know that using this query I can set time per session in mysql server
SET SESSION time_zone = '+04:00'
Question is how to detect this +04:00 (it can vary during year because of daylight saving time) part in PHP for my country?

Try using the timezone name (like America/Chicago) instead of +/- a set of hours. This should take into account daylight savings time.
You will need to load zoneinfo into your mysql database if you haven't already.
I will take a guess that perhaps you are in Azerbaijan? If so, you should use the IANA time zone id of Asia/Baku. This time zone alternates between a standard offset of +4:00 and a daylight offset of +5:00.
See "Time Zone != Offset" and "Time Zone Databases" in the timezone tag wiki.
If you need to do this in MySQL, you will need to load the IANA time zone database (aka "zoneinfo") into MySQL using mysql_tzinfo_to_sql. Thanks to datasage and kordirko for this tip.
But often the better approach is to only store UTC times in your database. You can do timezone translations directly in PHP using the DateTime and DateTimeZone classes. PHP also implements the same IANA time zone database, and you can find Asia/Baku on PHP's list of supported time zones.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With