Results 1 to 5 of 5

Thread: Add an hour to time

  1. #1

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Add an hour to time

    Hello all,

    I am trying to edit an existing php script. I need to know how I can add an hour to

    PHP Code:
    echo current_time'mysql' ); 
    The output from the following code shows differently

    PHP Code:
    echo current_time'mysql' )+3600
    please help asap.

    thanks
    Kanna

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Add an hour to time

    What is 'current_time'? What does it return? What does what it returns represent?

  3. #3

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Re: Add an hour to time

    PHP Code:
    echo current_time'mysql' ); 
    will return the current system time like
    Code:
    2008-10-04 15:16:07
    i would like to add an hour to that
    Kanna

  4. #4
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: Add an hour to time

    Although I don't have the code on me right now.

    You could break that date down into a UNIX timestamp, then add 3600 to it, then, format it back to its original value.

    Any one know a better method of doing so?

  5. #5
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Add an hour to time

    how about a date_add function? oh, how convenient

    PHP Code:
    $date = new DateTime("2008-10-04 15:16:07 ");

    date_add($date, new DateInterval("P5H"));
    echo 
    '<br />'.$date->format("d-m-Y").' : 5 Hours'
    My usual boring signature: Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width