Lan
Lan

Reputation: 1892

How to turn UTC+6 into local time in PHP

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

Upvotes: 0

Views: 1994

Answers (2)

calamari
calamari

Reputation: 244

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

php: setting a timezone by UTC offset

Upvotes: 1

DrRoach
DrRoach

Reputation: 1356

You should use date_default_timezone_set like so:

date_default_timezone_set(UTC+6 TIMZONE HERE);

Upvotes: 0

Related Questions