Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,859 questions

51,780 answers

573 users

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 151 views
151 views asked Aug 5, 2022 by avibootz
1 answer 191 views
1 answer 83 views
83 views asked Oct 26, 2023 by avibootz
...