Ayoub EL Khaddari
Ayoub EL Khaddari

Reputation: 47

php how to set timezone like (utc+1 utc-5) not (Europe/Amsterdam ...)

I want to display date and time for all countries in the world the problem is a more than 40 countries use utc+1 and it's difficult to specific timezones for each country exemple : london , morocco and niger has the same date and time

london =>  date_default_timezone_set('Europe/London');
 morocco =>  date_default_timezone_set('Africa/Casablanca');
 niger =>  date_default_timezone_set('Africa/Lagos');

my first question is why php not support :

date_default_timezone_set('utc+1')
date_default_timezone_set('utc+2')

and how i can define one time zone for all countries use utc+5 or utc+2

Upvotes: 2

Views: 3069

Answers (1)

Adrian Cornish
Adrian Cornish

Reputation: 23886

Did you look at the list of timezones? GMT ones will do what you want

https://www.php.net/manual/en/timezones.others.php

Etc/GMT+1   Etc/GMT+10  Etc/GMT+11  Etc/GMT+12
Etc/GMT+2   Etc/GMT+3   Etc/GMT+4   Etc/GMT+5
Etc/GMT+6   Etc/GMT+7   Etc/GMT+8   Etc/GMT+9
Etc/GMT-0   Etc/GMT-1   Etc/GMT-10  Etc/GMT-11
Etc/GMT-12  Etc/GMT-13  Etc/GMT-14  Etc/GMT-2
Etc/GMT-3   Etc/GMT-4   Etc/GMT-5   Etc/GMT-6
Etc/GMT-7   Etc/GMT-8   Etc/GMT-9   Etc/GMT0

Upvotes: 3

Related Questions