SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: math with dates

  1. #1
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Wyoming
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    math with dates

    I have a flat file with events listed in random order. I want to print a calendar with all the events for the next thirty days. I used a FOR loop to find the events by doing:

    $Today = date("Ymd");
    $Lastday = $Today+30;
    for ($Today = date("Ymd"); $Today <= $Lastday; $Today++)

    and then executing the commands. But it stops at the end of the month. I know this is because it is calculating today plus 30 as Sept 45. How can I get this to do the next 30 days, and at the end of the month (or year) continue to the next month (or year)?

    Thanks!

    Suzanne

  2. #2
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should work:
    PHP Code:
    for ($i 0$i<=30; ++$i) {
       echo 
    date('Ymd'mktime(000date('m'), date('d') + $idate('Y')));

    (Tested!)
    My name is Steve, and I'm a super-villian.

  3. #3
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Wyoming
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That did it! Thanks!


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
  •