Jump to content

Archived

This topic is now archived and is closed to further replies.

eddorey2k3

Problem converting UTC to GMT.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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]<?php
echo 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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.