0

i have a table with several timezones but just saved as string like "UTC+1" or "UTC-6" etc

how do i put that through the DateTime function to get what the time would be now in that zone

is it even possible?

am i close with this?:

$localtime = new DateTime("now", "UTC+6");

thanks

Lan
  • 1,874
  • 2
  • 20
  • 37
  • Have a look at this: http://stackoverflow.com/a/15626078/1203643 Feels like it should be that what you need. – Joshua Behrens Nov 15 '14 at 00:26
  • possible duplicate of [php: setting a timezone by UTC offset](http://stackoverflow.com/questions/7276304/php-setting-a-timezone-by-utc-offset) – vascowhite Nov 15 '14 at 09:02

2 Answers2

1

I've never tried this trick, but looks like this question is already been asked and answered:

php: setting a timezone by UTC offset

Community
  • 1
  • 1
calamari
  • 234
  • 1
  • 5
0

You should use date_default_timezone_set like so:

date_default_timezone_set(UTC+6 TIMZONE HERE);
DrRoach
  • 1,320
  • 9
  • 16
  • 3
    No, they should most definitely not do that. Plus, it doesn't answer the question of how to convert dates to another timezone. – Jon Nov 15 '14 at 00:22