Sbtract time from date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    Sbtract time from date

    I want to subtract three hours from current time. How can i do that?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    That depends.
    Can be as simple as:
    [code=php]
    $newDate = date("H:i:s", time() - (3600 * 3));
    [/code]
    If this is not what you need, please explain in greater detail, and show us the code you are using.

    Comment

    • ghjk
      Contributor
      • Jan 2008
      • 250

      #3
      Originally posted by Atli
      That depends.
      Can be as simple as:
      [code=php]
      $newDate = date("H:i:s", time() - (3600 * 3));
      [/code]
      If this is not what you need, please explain in greater detail, and show us the code you are using.

      Thank you so much.It is working. But i want to subtract from current time with date.
      Eg: 2008-05-15 15:03-(3 hours)
      Could you please tell me how can i do that?

      Comment

      • ghjk
        Contributor
        • Jan 2008
        • 250

        #4
        I have done it. Again thank you Atli.
        [PHP]
        $newDate = date("Y-m-d H:i:s", time() - (3600 * 3));
        echo "$newDate";
        [/PHP]

        Comment

        Working...