Help with date/time in PHP

Discussion in 'PHP' started by pmf123, Jul 30, 2008.

  1. #1
    I am trying to code the following:

    $expires = current date + 7 days



    and


    if current date > $expires echo('expired');


    can anyone help?
     
    pmf123, Jul 30, 2008 IP
  2. selling vcc

    selling vcc Peon

    Messages:
    361
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    $now = time();    // current unix timestamp
    $day = 3600 * 24; //numbers of seconds per day
    
    $expires = $now + 7*$day;
    
    PHP:
    
    $now = time(); // current unix timestamp
    if($now > $expires) 
      echo ('expired');
    
    PHP:
     
    selling vcc, Jul 30, 2008 IP
  3. pmf123

    pmf123 Notable Member

    Messages:
    1,449
    Likes Received:
    81
    Best Answers:
    0
    Trophy Points:
    215
    #3
    how would you display the actual time from that value?
     
    pmf123, Jul 31, 2008 IP
  4. selling vcc

    selling vcc Peon

    Messages:
    361
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    $time = time(); //current time stamp
    echo strftime ("%D", $time);
    
    PHP:
    To know what the %D means, and other possibilities you have, you must read this page http://www.php.net/strftime
     
    selling vcc, Jul 31, 2008 IP