setting website time to gmt?

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
i tried this but its a php5 function...any ways around? cause else the times on my site dont match :(
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Maybe something like:

PHP:
ini_set('date.timezone', '[Timezone Here]');

I'm not sure if that will work, or what the string is for timezones. The appendix page says:

http://us3.php.net/manual/en/ref.datetime.php#ini.date.timezone said:
date.timezone string

The default timezone used by all date/time functions if the TZ environment variable isn't set. The precedence order is described in the date_default_timezone_get() page.
 

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
ok this doesn't seem to be working :s i can use this in php right?
right befor i do this?
$date = date("Y-m-d G:i");
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
PHP:
$date = date("Y-m-d G:i");

That will return the date/time in the format between the "'s. I'm not sure, like I said in my orginal post if the ini_set() will set the date.timezone to the correct timezone, as I have not tested it myself. If you call that date() function like you posted AFTER you used the ini_set() function, (And ini_set() did successfully change the timezone), then your date() function should return the date/time in the timezone you set. If ini_set() did not work, your date/time will be returned in the CST (GMT -6) timezone.

You can check the return value from ini_set() to see what it returns. I believe if the function successfully changed the configuration value it will return the old value, and if it didn't, false. So if it "works", you can get the format of teh old timezone in the configuration file and see what the GMT timezone format should be.
 

hyeclass

New Member
Messages
348
Reaction score
0
Points
0
ok i got it working put inv(TZ=Europe/belgium) or something like that ...dont have the code open atm
but the one u gave works for php version 5 and higher but we have 4.xxx
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
"date.timezone "" PHP_INI_ALL Available since PHP 5.1.0."

My bad, I didn't see that.. :-/
 
Top