PHP Time Functions GMT?

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
dvdsecretz
Forum Newbie
Posts: 4
Joined: Wed Mar 05, 2003 2:30 am

PHP Time Functions GMT?

Post by dvdsecretz »

Hi guys

I installed a phpbb active dektop icon script and its working almost perfect.. its all ok except for the time displayed

for example, right now it tells me

Last Updated 05 Mar 2003 03:18 am

but it should say

Last Updated 05 Mar 2003 08:18 am

so it looks like its 5 hours behind..

i know the cause is that I and most my forum users are UK based but that server that hosts my forum is based in USA..

looking at this php file the time functions are
$time=time();
$time=date("d M Y h:i a",$time);
does anyone know if i can alter that or anything else to show GMT time.. i.e. 5 hours ahead from what its currently showing?

thanks in advance for any help.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You could do:

Code: Select all

$time=time() + (5*3600);
$time=date("d M Y h:i a",$time);
That will add 5 hours to the timestamp created by time().

Mac
dvdsecretz
Forum Newbie
Posts: 4
Joined: Wed Mar 05, 2003 2:30 am

Post by dvdsecretz »

twigletmac wrote:You could do:

Code: Select all

$time=time() + (5*3600);
$time=date("d M Y h:i a",$time);
That will add 5 hours to the timestamp created by time().

Mac
hey mac

thanks for that man, it worked but i have another question as it seems that it uses to display functions..

after i did what you said it now displays

Last Updated 05 Mar 2003 08:45 am (which is correct :) and that my time)

but the ime shown on the posts below i.e.

ADI Timing Test
on 05-03-03 @ 03:39

(the 03:39) should be 08:39 as thats when i posted it on the forums.

this is what i have in the script now
$time=time() + (5*3600);
$time=date("d M Y h:i a",$time);
and "time" is also mentioned in these bits
$sqlxx="SELECT a1.post_id AS postid, a1.poster_id AS poster, a1.forum_id, a1.topic_id AS topic, a1.post_time AS time, a2.post_subject AS subject, a2.post_text AS text FROM phpbb_posts a1, phpbb_posts_text a2, phpbb_forums a3 WHERE a1.post_id = a2.post_id AND a1.forum_id = a3.forum_id";
and
$sqlxx .= " ORDER BY a1.post_time DESC";
$box_content .="<tr><td ><font size="$fontsize" color="$fontcolor" face="$fontheaderface"><img src="$POST_IMAGE " width="10" height="15" ><a href="" . $phpbb_root_path . "/viewtopic.php?t=" .$post["topic"] . "" title="Posted by:" . $author["username"]. " &nbsp;&nbsp; In:" . $forum["forum_name"] . "">&nbsp" . $post["subject"] . "</a><br> on " . date("d-m-y ", $post["time"]) . " @ " . date("H:i", $post["time"]) . "</font></td></tr>";
print("<table width="250"><tr><td>" . $box_title . "</td></tr><tr><td><font size="$fontsize" color="$fontcolor" face="$fontheaderface">Last Updated $time</font></td></tr><tr><td>" . $box_content . "</td></tr></table>");
^^ the time in that last one is all ok, its just on the thread post times thats still 5hours off..

here is a snapshot of what i mean

Image

sorry for all the text heh

DvD
dvdsecretz
Forum Newbie
Posts: 4
Joined: Wed Mar 05, 2003 2:30 am

Post by dvdsecretz »

me again

looks like this is the bit that is still showing 5 hours begind
on " . date("d-m-y ", $post["time"]) . " @ " . date("H:i", $post["time"]) . "</font></td></tr>";
any ideas?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

The date() function takes two arguments, the formatting options (the "H:i" bit) and a timestamp (in this case $post["time"]) so to make it display a time 5 hours later than the time it stored for posting you do pretty much what you did before:

Code: Select all

date("H:i", $post["time"]+(5*3600))
Mac
dvdsecretz
Forum Newbie
Posts: 4
Joined: Wed Mar 05, 2003 2:30 am

Post by dvdsecretz »

thanks for that man

that sorted it perfectly ;o))

much appreciated

regards

DvD
Post Reply