开发者

Smart way to create a date functionality?

Current MySQL table schema: "Date" column with yyyy-mm-dd values

Assuming you are building a web app to rent out XBox's. Would you:

  1. Create a a few checkboxes with "Every Monday," "Every Tuesday," "etc..." (Implication: If it's every Monday, how would you insert dates of only Monday's into the DB? Perhaps only insert the Monday's for the next three months initially and auto-increment and keep the tables light?"

  2. Use a multi-datepicker for users to select multiple dates (Implication: User开发者_StackOverflow社区 experience drops since the user will need to select more dates as time progresses?)

  3. Other options?

How would add "hours" in addition to dates?


Store the data separately:

  • Start date - the start of the range
  • End date - the end of the range
  • Days of the week - the days of the week during the range (store this as a JSON array)
  • Hours per day - the hours per day (store this as a JSON object, with either start/end time per day of the week)


Try taking a look at Google Calendar add event page. They organize the times very smartly. It should give you some ideas for it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜