Woodburn2006 Posted September 10, 2007 Share Posted September 10, 2007 i am in the uk but my server is american so everytime i use: $time = date('H:i'); it comes up with a time that is 6 hrs behind my time, is there anyway i can rectify this? Quote Link to comment Share on other sites More sharing options...
almightyegg Posted September 10, 2007 Share Posted September 10, 2007 gmdate() Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2007 Author Share Posted September 11, 2007 thanks, that has made it better but it is still 1 hour behind our time? any ideas? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 Either change the timezone setting on the server, or add the difference in hours. Set a constant like define('HOURS_DIFFERENCE', 6*3600); and always add HOURS_DIFFERENCE to the time. Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2007 Author Share Posted September 11, 2007 ok cool ive had a look on the server and cannot find a way of changing the time on it. i dont understand how you mean, i know basic php but havnt had to use times and define yet Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 You'll want to have a config file which contains all of your important site wide data, such as the time difference constant. Include it on all your pages. Then when you need to use a timstamp, just add that constant to it. (Or it might be subtract, I get time zones confused which is ahead and which is behind, but you'll figure it out. If it goes more off use subtract). Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2007 Author Share Posted September 11, 2007 ok, yeah i got a functions page that has all of the functions i would use over the whole site on it. i need to add 1 hour on to the time so what code would i put in my functions page to get that? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 You seriously cannot figure that out from what I said? I told you how to add six hours, and you're asking how to add one? Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted September 11, 2007 Author Share Posted September 11, 2007 yeah because when i use gmdate() its only 1 hour behind but if i use date() then it is 6 hours behind Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 So use date and add six hours, or use gmdate and add one hour. date("H:i:s", time()+DIFFERENCE); Quote Link to comment Share on other sites More sharing options...
MadTechie Posted September 11, 2007 Share Posted September 11, 2007 define('HOURS_DIFFERENCE', 6*3600); date("H:i", time()+HOURS_DIFFERENCE); EDIT: jesirose beat me (but it's her code, lol) Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 well obviously the constants need to have the same name... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.