How to set time zone and get the current time of the specified country with PHP

1 Answer

0 votes
date_default_timezone_set("America/New_York");
echo "The time in America/New_York is: " . date("h:i:sa") . "<br />";

date_default_timezone_set("Asia/Tokyo");
echo "The time in Asia/Tokyo is: " . date("h:i:sa") . "<br />";

date_default_timezone_set("Israel");
echo "The time in Israel is: " . date("h:i:sa") . "<br />";

date_default_timezone_set("Europe/Berlin");
echo "The time in Europe/Berlin is: " . date("h:i:sa") . "<br />";

/*
run:
  
The time in America/New_York is: 05:24:50am
The time in Asia/Tokyo is: 07:24:50pm
The time in Israel is: 12:24:50pm
The time in Europe/Berlin is: 11:24:50am
 
*/

 



answered Nov 27, 2015 by avibootz

Related questions

1 answer 169 views
169 views asked Aug 5, 2022 by avibootz
1 answer 203 views
1 answer 98 views
98 views asked Oct 26, 2023 by avibootz
...