Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

Need help with PHP

  • Please log in to reply



    Spyware Veteran

  • GeekU Moderator
  • 33,084 posts
I'm a total newb with PHP and I have installed a guestbook that displays the time of the posts.

I found this piece of code which I think adds the date and time to the posts:

echo ' <span class="ddgb_h">' . _WRITTEN_ON . "</span> " . date(_FORMAT_DATE, $data['timestamp']) . " " . _WRITTEN_ON_TIME . '<br />' . "\n";

The question is pretty simple. The answer may or may not be.
How do I add 7 hours to the displayed time?

I suspect the script adds the time at the server which is in a different time-zone then most visitors of the site I'm working on.
  • 0




    Member 1K

  • Retired Staff
  • 1,411 posts
Hi there :whistling:

$data['timestamp'] <-- I am assuming that variable is a unix timestamp?

If so, unix time stamps are in seconds, so just add the amount of seconds (60*60*7=25200)


$NewTimeStamp = $data[timestamp] + 25200;

echo ' <span class="ddgb_h">' . _WRITTEN_ON . "</span> " . date(_FORMAT_DATE, $NewTimeStamp) . " " . _WRITTEN_ON_TIME . '<br />' . "\n";

If the date isn't stored in a unix timestamp then this code won't work and we'll have to find how the date is stored.

Edited by mpfeif101, 11 November 2006 - 04:24 PM.

  • 0



    Spyware Veteran

  • Topic Starter
  • GeekU Moderator
  • 33,084 posts
Thank you bundles Matt.

That worked like a charm. :whistling:
  • 0

Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP