Help with time zone in php code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Help with time zone in php code?

Post by me666 »

Hey.... ive used this code to the the current date and time to a table when you login using my script....

Code: Select all

$todaydate = date('F j, Y - h:i A');
All works fine, the date and time are added as should, BUT the time is an hour erlier than i want it to be, so if u login at 3:30pm it saves it as 2:30pm... Is there a piece of code any1 knows that would alow me to change the timezone so it represents the correct time i want?
Thanks alot for any help any1 can give me :)
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Help with time zone in php code?

Post by aceconcepts »

Never used it before, but looks interesting: http://uk.php.net/localtime
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Re: Help with time zone in php code?

Post by me666 »

ahh thanks, that helped me a little but not much to be honest.... i have realized that the timezone in my script is correct, but its just not displayingit as daylight savings, therefor making it an hour early, but come next month when the clocks go back it will be the correct time, if u get what i mean... so now im looking for a script to determin if its daylight savings or not, is there a way of doing that?

thanks :)
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Help with time zone in php code?

Post by Weirdan »

what does the following show:

Code: Select all

 
var_dump(date_default_timezone_get());
 
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Re: Help with time zone in php code?

Post by me666 »

i get this error...
Fatal error: Call to undefined function: date_default_timezone_get()

thanks
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Help with time zone in php code?

Post by Weirdan »

Then you must be having really old and rusty php... still on php4 by any chance?
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Re: Help with time zone in php code?

Post by me666 »

to be honest im not sure :S i use an online server and alot of my code was orriginally from templates. thanks for the help anyways... i will just have to change it myself when dst comes in and goes out, i have it running no problem just have to ad a little code to change the time back 1 hour, and remove it when dst is over so it is corrdct, if that makes sence. It will do as it it :)
thanks agen for the help
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Re: Help with time zone in php code?

Post by me666 »

yea, just looked at my servers website and the php version is 4.4.1
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Help with time zone in php code?

Post by Weirdan »

me666 wrote:yea, just looked at my servers website and the php version is 4.4.1
Shame on your host for not updating in time... 4.4.1 is almost 3 years old.
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Re: Help with time zone in php code?

Post by me666 »

yea thats the free account wich i use, the paid account is 5. something
Post Reply