Chris
Chris

Reputation: 58242

What is the closest thing to 'date_default_timezone_set' in PHP4?

How can I achieve a similar effect to 'date_default_timezone_set' in PHP4? I need to use the date() function while taking into account local time zones and also day light saving.

Edit: example with putenv:

putenv('TZ=Australia/Victoria');    
echo date('l jS \of F Y h:i:s A');

Outputs

Thursday 6th of October 2011 07:36:49 PM

Actual time here in Victoria

Friday 7th October 2011 06:36:49 AM

Upvotes: 5

Views: 986

Answers (4)

user3165160
user3165160

Reputation:

You can check with daylight function: date("I",time());

Upvotes: 0

adilbo
adilbo

Reputation: 970

You can use:

ini_set("date.timezone", "Europe/Berlin"); // PHP 4

to sets the default timezone used by all date/time functions in a script!

Instead of using this function to set the default timezone in your script, you can also use the INI setting date.timezone to set the default timezone.

Upvotes: 1

Chris
Chris

Reputation: 58242

No solution came from this question. I ended up doing a manual work around using the Flash Player.

Upvotes: 2

Jeff Day
Jeff Day

Reputation: 3717

It looks like the TZ environment variable is what you would need to use for this. Using putenv() you should be able to dynamically change the timezone.

Upvotes: 1

Related Questions