1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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,447
    Likes Received:
    75
    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