SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry How to do Calandering work in PHP?

    Hi,

    I'm building a hotel reservation system for a client. I have a table called 'rooms' in the database, where there are records such as roomId = 5, roomType='Single'.

    I need a system using which the client can set the availability of rooms during a certain period. For example, he should be able to set that during 1st November, 2007 - 1st December, 2007, all rooms of type 'single' are closed on saturdays and sundays, but available for the rest of the week during the entire month.

    How can I code something like this? Questions:

    1) Is there a way to get the 'day' on a particular date. E.g pass on a date such as 15th october, 2007 and have 'Sunday' as the return value.

    2) How should I structure the database to store the availability schedule for something like this? I was thinking about inserting a record in a table for each day, (so about 30 records for during 1st november - 1st december), each record storing the roomId, the date, the day (e.g sunday, monday, etc) and the status (available, closed).

    Does anyone have any better ideas? Please share!

  2. #2
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) Use date() but add the optional timestamp

  3. #3
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the answer galen. How can I build a timestamp out of a regular date?

  4. #4
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    date('format string', mktime());

    date('l', mktime(0,0,0,10,15,2007))

    would give you the day of the week for oct 15 2007

  5. #5
    FBI secret agent digitman's Avatar
    Join Date
    Sep 2004
    Location
    Work
    Posts
    697
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gotcha, thanks pal! One last question if you don't mind, what do you think about the method I'm thinking about using for this issue (i.e question # 2) of my original post). Any comments about that?

  6. #6
    SitePoint Zealot fatnic's Avatar
    Join Date
    Aug 2006
    Location
    Lincoln, UK
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would probably be easier to just store the dates that they are closed, rather than every date.


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
  •