|
|
|
|
![]() ![]() |
May 25 2005, 03:21 PM
Post
#1
|
|
|
Member [Level 2] ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 78 Joined: 25-April 05 Member No.: 6,158 |
So this is probably a basic and lame question, but how can I convert dates so I can then sort them?
Right now, I have each part of a date as a separate variable: $month, $day, $year. I'd like to store them in the database as epoch. This way when I do a query I can sort them by date. I can figure out the datatype for the database later. I would also need to convert an epoch to Month-Day-Year later on when I want to display this. I'm sure this isn't too complicated but I figured asking for some suggestions anyway. Thanks! |
|
|
|
May 25 2005, 04:49 PM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 125 Joined: 11-May 05 Member No.: 6,903 |
well i have expirience working with dates ... the way i sugget you to mange the date is the next ... work with them as Long variables .... with the next format
YYYYMMDD so when you try to sort them, as they are numbers, for example a date of the year 2004 will always be minor of a date of 2005 with that base ... ex. february 1, 2004 -> 20040201 (minor) february 1, 2005 -> 20050201 and the same is for the months of the same year ... february 1, 2005 -> 20050201(minor) march 1, 2005 -> 20050301 and the same for the days february 1, 2005 -> 20050201(minor) february 4, 2005 -> 20050204 so when you make a query to your DB like this SELECT YourDate, YourData FROM YourTable ORDER BY YourDate the result will be this 20040101 20040201 20040231 20050101 ... and so on and when you show the date to the user yo only give to it a format as you want it dd/mm/yyyy or mm/dd/yy .. as you wish |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 23rd November 2008 - 10:36 AM |