1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

evaluate date where > 2 weeks ago

Discussion in 'PHP' started by mcyi2mr3, Sep 13, 2006.

  1. mcyi2mr3

    mcyi2mr3 New Member

    Joined:
    Sep 13, 2006
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    hi all i have a date on a php page and i need to check if that date (
    in this format : 2006-06-04) is more than 2 weeks ago. How can i do
    this most efficiently?

    regards

    marc
     
  2. dux

    dux New Member

    Joined:
    Oct 5, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    if $date is the variable holing the date. Do the following

    Code:
    <?php
    $timestamp=strtotime($date);//makes a timestamp from the date sting.
    $twoweeks = mktime(0, 0, 0, date("m"), date("d")-14,  date("Y"));//Gets the timestamp for 14 days ago
    if ($timestamp<$twoweeks)//if the date is over two weeks ago
    .....
     
    Last edited: Oct 5, 2006
  3. mcyi2mr3

    mcyi2mr3 New Member

    Joined:
    Sep 13, 2006
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    The problem is already solved but anyways thanks for the help and I am looking forward to some more help in the near future in PHP as I am moving on with the language
     

Share This Page