Simple calendar event system
Moderator: General Moderators
Simple calendar event system
Dates and times are so much fun to work with
I want to create a simple event calendar which allows me to post events with a specific date and time, and allowing recurring events. I'm trying to figure out how to best store the time and date information. For everything else on the site I use unix timestamps. I think for this specific case, it would be better to store the data differently to make it easier to query. I planned to just split every thing up, having a day, month, year column, a time column, and the recursion column. Is there a better way to do this?
Re: Simple calendar event system
You can use a mysql DATETIME Column in the format YYYY-MM-DD HH-MM-SS
eg.
This should be simple enough to query by date.
I would use a unix timestamp and the php strtotime() function for this though. Like:
This function is VERY useful for me.
A user can type in today or next tuesday and you can still find matching events. To check for errors, strtotime returns false if a timestamp is not produced.
eg.
Code: Select all
2010-03-15 22-06-30I would use a unix timestamp and the php strtotime() function for this though. Like:
Code: Select all
strtotime($time) //make any date format a timestamp 03.04.01,05/06/10, tomorrow, today, next mondayA user can type in today or next tuesday and you can still find matching events. To check for errors, strtotime returns false if a timestamp is not produced.
Re: Simple calendar event system
I would stick with the timestamp, since you can do whatever you may need to do, even though it takes a bit more code, sometimes. If you split the representation of dates and times, you're inventing the whole timestamp concept all over again, and when, later down the line, you find that you need to do something else, you may not be able to do it. That's why someone invented the timestamp, years ago, and why it has been used without substantial change ever since.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Simple calendar event system
I think Luke has an iCalendar library that has a lot of this functionality. You might want to try it.
http://code.google.com/p/qcal/
http://code.google.com/p/qcal/
(#10850)