11

I'd like to write a function that can convert a time in EST (USEast Standard Time) to a time in another local timezone.

The inputs will be "time in EST" in the form 'Y-m-d H:i:s' (i.e. 2011-08-23 05:05:35), "City" "State", and "Country"

The function should return the local time (i.e. if the city, state, country is San Francisco, California, USA, and time in EST is 2011-08-23 05:05:35, function should return 2011-08-23 02:05:35)

I tried to figure it out from php.net but it seems like I need a continent to specify a timezone...and I didn't know how to convert a country to a continent.

Thanks

Problematic
  • 17,567
  • 10
  • 73
  • 85
Mark
  • 161
  • 7
  • 1
    http://www.geekality.net/2011/08/21/country-names-continent-names-and-iso-3166-codes-for-mysql/ – HyderA Aug 25 '11 at 22:03
  • Is "San Francisco, California, USA" freeform text input or some predefined value? Where does that come from and how many possible values are there? – deceze Aug 26 '11 at 04:03

2 Answers2

18

the PHP function date_default_timezone_set('EST'); accepts timezone as EST or GMT maybe this can be a good alternative to your problem.

Book Of Zeus
  • 49,509
  • 18
  • 174
  • 171
17

I prefer:

date_default_timezone_set('America/Los_Angeles');
Pat R Ellery
  • 1,696
  • 3
  • 22
  • 40