I've trolled thru the newbie and code sections and cant really seem to find what im after. I have also gone thru the 4 books i have here and the php online manual and still cant really understand what im doing.
I have a dbase which has to store a date entered by some computer illiterate data entry people. So i wanted to make it as idiot proof as possible. With this in mind i have broken the date up into 3 entry fields: Day, Month (both pulldown menu options) and a 4 int Year field. The code for these seems to be no problem.
I have 4 pages: addrecord, updaterecord, displayrecord, and recordlist.
My main problem is whether to store the data as a MySQL date or a Unix timestamp. I need to be able to sort and search for specific dates, but display them as date('jS m Y') (im in the UK). Also once stored i need to be able to break them up into component day, month and year variables so that i can display them in the date field/menus when i want a user to update.
I have a little function which doesnt seem to be working because of the formatting i place in the date() function, but im not sure how to correctly format it so that it stores the data correctly for the MySQL format.
function GetDateString($theday, $themonth, $theyear)
{
$theUnixdate = mktime(0,0,0,$themonth,$theday,$theyear);
$thedate = date('Y-m-d',$theUnixdate);
return $thedate;
}
Another portion of this problem is how do i use the date function to display data stored as a MySQL date format as the date() function uses the unix timestamp eg date(string, unixtimestamp) and not date(string, MySQLdateformat).
Eventually this data will be searchable for events that occur on a particular date (more than likely also selected via pulldown menus similar to how the data is entered).
Is anyone able to offer a suggestion for this or am i better off storing dates as a Unix timestamp? This also poses more questions as i will still need to extract the day, month, year portions at some stage.