eddorey2k3 Posted May 20, 2006 Share Posted May 20, 2006 Ok. I have a script that pulls out the time it was run, and puts it into a database. That looks like this.[code]$date = date("DdSF,Y");$time = date("g:i:sa");[/code]I have no problem with this, it works fine. However, I do have a problem with the time it pulls out. Whilst it works fine, since it's in UTC and I'm in GMT it is always 5 hours behind. I'm looking for a way to solve this. I've been told that I need to add 18000 seconds to the time (Since that's 5 hours). As far as I can see, this will work, except for DST.Any ideas how I can either get it to add 18000 all the time, or work out the time for DST as well?Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/10058-problem-converting-utc-to-gmt/ Share on other sites More sharing options...
zq29 Posted May 20, 2006 Share Posted May 20, 2006 As far as I was aware, GMT and UTC are the same thing.To add 5 hours, you could do it like this. You can add 18000 to the seconds if you prefer though output would be the same.[code]<?phpecho date("DdSF,Y g:i:sa",mktime(date("g")+5,date("i"),date("s"),date("m"),date("d"),date("Y")));?>[/code]As for making it DST correct, I guess you could use a switch() to match the current month, and if DST applies add/remove an hour. Quote Link to comment https://forums.phpfreaks.com/topic/10058-problem-converting-utc-to-gmt/#findComment-37429 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.