Jump to content

Problem converting UTC to GMT.


eddorey2k3

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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.