Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts

    My count stopped adding???

    Hi,

    The subject line isn't a good indication of my problem, best I could come up with.

    Here's my code:

    PHP Code:
    $now time();
        
    $count 0;
        while(
    $count 90){
            
    $count++;
            
    $Dnow date("F j, Y",$now);
            
    $now strtotime($Dnow);
            
    $startdate.="<option value=\"$now\">$Dnow</option>";
            
    $now $now 86400;
        } 
    // while 
    The odd thing is, once it gets to roughly 74 or so, or more specifically - November 4th, it stops adding to $now. It still counts, but what I end up with is all dates between now and Nov 4th, once it hits Nov 4th it continues to list Nov 4th until $count equals 90!

    Now unless I am missing something really obvious, this seems extremely odd!?!?!

    Any help apprecaited!

    Taylor.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    PHP Code:
    $now time();
        
    $count 0;
        while(
    $count 90){
            
    $count++;
            
    $Dnow date("F j, Y",$now);
            
    //$now = strtotime($Dnow);
            
    $startdate.="<option value=\"$now\">$Dnow</option>";
            
    $now $now 86400;
        } 
    // while 
    Try this ^

  • #3
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    Thanks for the reply. That does fix the problem, HOWEVER - it means I get a result I'm not after. My purpose for having the strtotime is because I want the value of midnight, not the current hour and minute - because later in the script I add to this value according to which hour in the day I want.

    For example, if I want 620pm I do the value of $now + 66000... Make sense?

    Perhaps there is another way of doing this instead of doing the strtotime?

    Any suggestions appreciated!

  • #4
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    Oh nevermind! I just realised, after I post the value I can then do strtotime to change it to the midnight value.

    Thanks for the help!

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Use mktime(), you can generate the day/month/year from $now & date().


  •  

    Posting Permissions

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