date

Discussion in 'PHP' started by harryoxford, Sep 18, 2009.

  1. #1
    Hi.. I need to insert a time into an MySQL DB. It needs to be done by the php, as opposed to the database doing the maths...

    What is the best way to insert a "now + 24 hrs" etc into a db, I just need the value, not the SQL Statement..
     
    harryoxford, Sep 18, 2009 IP
  2. phprightnow

    phprightnow Peon

    Messages:
    296
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Personally, I use Linux Timestamps to handle all my time/date issues.

    http://www.php.net/time

    Here's a code I would use.

    $one_day = (60 * 60) * 24; // Calculate one day's time in seconds
    $new_time = time() + $one_day; // Add the current time to your one day variable
    mysql_query("insert into `table` VALUES(".....,'".time()."',...."); // Your insert code here, obviously replace the ...'s with your other fields
    PHP:
     
    phprightnow, Sep 19, 2009 IP
  3. sunchiqua

    sunchiqua Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $tomorrow = time() + 86400; // +24h
    PHP:
     
    sunchiqua, Sep 21, 2009 IP