1

I need to display a date and time in gmt format into est timezone time for ex my given time is

12:14 PM Thursday, 10 December 2015

and the Est time that want display is

1:44 AM Thursday, 10 December 2015

I used this code

date_default_timezone_set('EST'); 
echo date('m/d/Y g:i a', strtotime($row['date_time']));
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
Gugan Abu
  • 546
  • 1
  • 4
  • 17
  • Do you *actually* mean EST (which is always UTC-5), or do you mean Eastern Time (which is UTC-5 in winter, and UTC-4 in summer)? It's important to understand the difference. Next, what happens with the code you've already got? Am I right in thinking your server is in the Indian time zone? – Jon Skeet Dec 10 '15 at 06:49
  • Additionally, when you say a "given" date and time - are you expecting that date and time to be in the Indian time zone, or some other time zone? – Jon Skeet Dec 10 '15 at 06:51
  • @JonSkeet you right i am using indian time zone, now i want to display time in EST zone only. – Gugan Abu Dec 10 '15 at 06:54
  • When executing above code it displays given time only. It doesn't convert time into EST zone – Gugan Abu Dec 10 '15 at 06:55
  • Again, do you mean EST or Eastern Time? And again, what time zone is the value from your row in? Where are you getting it from? – Jon Skeet Dec 10 '15 at 06:57
  • there is no timezone that PHP recognizes for Eastern standard time.use utc – Nero Dec 10 '15 at 06:58
  • @JonSkeet Can you specify which time zone is used on NY, Now the date time value in IST – Gugan Abu Dec 10 '15 at 07:03
  • 1
    The New York time zone is "America/New_York" - that's one example of Eastern Time. – Jon Skeet Dec 10 '15 at 07:06
  • It seems like this should really just be a matter of parsing, changing time zone, then formatting again. Voting to close as a duplicate of a time zone conversion question. – Jon Skeet Dec 10 '15 at 07:07
  • I tried this code, working fine now. Thanks for your effort. $datetime = new DateTime($row['date_time']); $ny_time_zone = new DateTimeZone('America/New_York'); $datetime->setTimezone($ny_time_zone); echo $datetime->format('m/d/Y g:i a'); – Gugan Abu Dec 10 '15 at 08:24

0 Answers0