datetime - PHP Timezone Conversion / PHP Date not displaying correct timezone -


The default timezone for my server and MySQL database is set in GMT. My PHP code converts on the date that the user's local Timezone (formerly in this case) is displayed:
  $ OPENED_DATE = '2013-03-20 21:05:00' $ OPENED_DATE = new date time ($ OPENED_DATE); $ OPENED_DATE- & gt; Settimejone (new dated timezone ('America / New York'));   

Then I will produce a date for the user:

  $ OPENED_DATE = Stratom ($ OPENED_DATE-> format ('Ymd H: i : S ')); $ OPENED_DATE = Date ('FJ, Y G: IAT', $ OPENED_DATE); Output of $ OPENED_DATE: March 20, 2013 5:05 PM GMT  

Actual time is displayed correctly but 'T' in 'Output' is still displaying GMT. Is there a way to do this that we display GMT default not to change the timezone? The only way to get me to do this is to use date_default_timezone_set to switch to user's timezone , Then go back to GMT but I think that should be done in a more efficient way ...

Thank you!

These two lines are unnecessary

  $ OPENED_DATE = strtotime ($ OPENED_DATE-> Format ('YMD H: I: S')); $ OPENED_DATE = Date ('FJ, Y G: IAT', $ OPENED_DATE);   

This is a call to the date () which is outputting the wrong timezone.

Why not just try: $ OPENED_DATE = $ OPENED_DATE-> Format ('FJ, YG: IAT'); Time zone is set in the

date time object, but once you change it to timestamp and use date () For that time the server timezone is used, I think it is enough to do the date formatting to use only the datetime object that you want.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -