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.

backdate PHP script

Discussion in 'PHP' started by Bangrak47, Jun 17, 2009.

  1. #1
    I am not a programmer, sometimes it difficult to get some thing done.
    So, I have some work for PHP, I try to make a PHP code for getting the display date not today but the past such as 6 day. It quite hard for me. Any suggestion!

    Thankshttp://forums.digitalpoint.com/images/icons/icon11.gif
    SEMrush
     
    Bangrak47, Jun 17, 2009 IP
    SEMrush
  2. Nasukai

    Nasukai Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This would be the function you want to look into if what I'm thinking is the same as what you are trying to explain:

    php.net/mktime
     
    Nasukai, Jun 17, 2009 IP
  3. newgenservices

    newgenservices Well-Known Member

    Messages:
    862
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    105
    Digital Goods:
    1
    #3
    This would be simple :)

    
    <?php
    $days_before = 6; // Number of days before today
    $current_date = date('Y-m-d');
    $str = strtotime($current_date)-(86400*$days_before); //1 day has 86400
    
    echo date('Y-m-d',$str); // Output : 2009-06-12
    
    echo "<br>"; // Line break
    
    echo date("F j, Y",$str); // Output : June 12, 2009
    ?>
    
    Code (markup):
     
    newgenservices, Jun 18, 2009 IP
    Vooler likes this.