SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to proceed (Time Issue)

    Hi guys

    OK this is what I need to do

    I have a start time

    2009-06-03 08:00:00
    and a end time

    2009-06-03 17:00:00
    and a intervals of

    60 minutes

    How can I generate via php a table like this


    08:00
    09:00
    10:00
    11:00
    12:00
    13:00
    14:00
    15:00
    16:00

    Thanks in advance

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $StartTime StrToTime('2009-06-03 08:00:00');
    $EndTime StrToTime('2009-06-03 17:00:00');
    echo 
    '<ul>';
    for(
    $i $StartTime$i <= $EndTime$i += 60 60){ //1 hour. I put the one so that it's easier for you to change to, say, 2 hours etc
         
    PrintF('<li>%s</li>'Date('H:i'$i));
    }
    echo 
    '</ul>'
    If you DONT want to include 17:00, change the for condition from <= to <
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you. Exactly what I needed


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
  •