how to subtract one hour from time?

Discussion in 'PHP' started by alhen, Jul 31, 2007.

  1. #1
    Hello,
    I'm hoping there's a really easy way to subtract one hour from the time I'm entereing into my table. the code I have is:
    $time = (date ("h:i:s A"));
    Code (markup):
    But the server is in eastern time and I'm in central time.

    Please tell me it's easy!

    Thanks,
    --
    alhen
     
    alhen, Jul 31, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You just need to take off 3600 seconds from the timestamp:
    $time = date("h:i:s A", time()-3600);
    PHP:
    PHP5 has a new date object and timezone handling functions but unless you're working with times a lot, that's probably overkill.
     
    rodney88, Jul 31, 2007 IP
  3. alhen

    alhen Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks rodney88, problem solved!
    --
    ~alhen
     
    alhen, Jul 31, 2007 IP
  4. nagasharmi

    nagasharmi Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    $d=getdate();
    echo $d[hours];
    echo $d[minutes];
    echo $d[seconds];
     
    nagasharmi, Aug 2, 2007 IP