Welcome Guest, Not a member yet? Register   Sign In
Dealing with dates
#1

[eluser]fakeempire[/eluser]
I'm working on an application that has "events" with a date.

I'm trying to figure out the easiest and cleanest way to deal with the events. First I dont have any limitations or requirements so I'm not sure if the the unix timestamp is easier to work with or or mysql's datetime field.

Really the only functionality I want is to be able to sort by month during a list --

ie

February
-[date & time] - Event Title A
-[date & time] - Event Title B
March
[No Events]
April
-[date & time] - Event Title C

I'm really just not sure how to go about it and which type of time would be best to use.

Thanks guys
#2

[eluser]Phil Sturgeon[/eluser]
UNIX time or MySQL time both order fine. Pick one and just use:

Code:
$this->db->orderby('date');

If you think you will be doing lots of mathmatics on the date (getting items within the last 7 days, timespans, date format changes, etc) then use UNIX. If you want a simple "store and show" then use MySQL. Otherwise you will be converting back to UNIX every time you want to do some convertions.




Theme © iAndrew 2016 - Forum software by © MyBB