PHP Date function help required

4 replies
I am getting current date in php using date function but what I want is date before 15 days. I mean if today is 15th jan then i want it 1st Jan as a date.

Thanks
#date #function #php #required
  • Profile picture of the author bugtrack
    You can use strtotime function for that here is an example for what you are looking for

    PHP Code:
    date('Y-m-d'strtotime('-7 days')) 
    Hope it wills olve your problem
    {{ DiscussionBoard.errors[8248893].message }}
    • Profile picture of the author Paul Moss
      Or you can use if you are using greater than php 5.3


      $date = new DateTime(date("Y-m-d"));
      $date->modify('-15 day');
      echo $date->format('Y-m-d');
      {{ DiscussionBoard.errors[8250457].message }}
  • Profile picture of the author weaveronline
    Hope this helps

    <?php
    echo date("jS F", strtotime('+15 days'));
    ?>
    Signature

    Thanks & Regards,
    Reach us at dukeduke600@gmail.com.
    Web Design| Logo Design | Banner Design | Web Development | Mobile Applications [iPhone/iPad/Android/Windows Phone]

    {{ DiscussionBoard.errors[8253460].message }}
  • Profile picture of the author octalsoftware
    <?php
    echo date("Y/m/d") . "<br>";
    echo date("Y.m.d") . "<br>";
    echo date("Y-m-d");
    ?>

    output::
    2013/07/12
    2013.07.12
    2013-07-12
    {{ DiscussionBoard.errors[8271019].message }}

Trending Topics