#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    sane issue


    http://forums.devshed.com/php-development-5/php-list-days-between-two-dates-714679.html

    i try to all date list between two dates but output show only 1970/01/01.

    Code Here...

    <?php
    if(isset($_REQUEST['Submit']))
    {
    $startdate = $_POST['start_date'];
    $enddate = $_POST['end_date'];

    $period = (strtotime($enddate) - strtotime($startdate))/(60*60*24);

    do {
    echo "This " . @$dateinfo . "<br>";

    $dateinfo = date ( 'Y-m-d' , strtotime ( '+1 day' , strtotime ( @$dateinfo ) ) );
    $period-- ;
    } while ($period > 0);

    }
    ?>

    <form id="form1" name="form1" method="post" action="">
    <table width="0" border="0">
    <tr>
    <td>First Date</td>
    <td><input type="text" name="start_date" /></td>
    </tr>
    <tr>
    <td>Last Date</td>
    <td><input type="text" name="end_date" /></td>
    </tr>
    <tr>
    <td colspan="2" align="right"><input type="submit" name="Submit" value="Submit" /></td>
    </tr>
    </table>
    </form>
    Last edited by requinix; October 6th, 2012 at 03:06 AM.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    issue in date


    i also use this code i find output show only 2012-01-01 to 2012-01-10 and output show
    This 1970-01-02
    This 1970-01-03
    This 1970-01-04
    This 1970-01-05
    This 1970-01-06
    This 1970-01-07
    This 1970-01-08
    This 1970-01-09
    This 1970-01-10
    default date
    here my code...


    if(isset($_REQUEST['Submit']))
    {
    $startdate = $_POST['start_date'];
    $enddate = $_POST['end_date'];

    $period = (strtotime($enddate) - strtotime($startdate))/(60*60*24);

    do {
    echo "This " . @$dateinfo . "<br>";

    $dateinfo = date ( 'Y-m-d' , strtotime ( '+1 day' , strtotime ( @$dateinfo ) ) );
    $period-- ;
    } while ($period > 0);

    }
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    You never define a starting value for $dateinfo.

    As a general rule, if you ever find yourself having to use the @ operator it means you are doing something wrong. Remove that from your code, turn on notices and then PHP will tell you that you forgot to define a starting value for $dateinfo.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo