Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Need help with PHP


  • Please log in to reply

#1
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 33,101 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

Advertisements


#2
mpfeif101

mpfeif101

    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)

so..

$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

#3
Metallica

Metallica

    Spyware Veteran

  • Topic Starter
  • GeekU Moderator
  • 33,101 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