SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    to get a future date

    hi,

    I have a string like this.

    '2007-03-10'

    and I want a date just after 4 days from the date in the string.

    ie, i want '2007-03-14'.

    The original string may contain any future date say '2007-08-28'.

    The result should be '2007-09-01' in this case.

    Thanks.

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try out this:
    PHP Code:
    $prevdate '2007-03-01';
    $stmp_prevdate strtotime($prevdate);
    $stmp_nextdate $stmp_prevdate + (3600*24*4);
    echo 
    date('Y-m-d',$stmp_nextdate); 
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    echo date("Y-m-d"strtotime("2007-08-28 + 4 days")); 
    see strtotime

    FAQ anyone?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •