Hi,
im having massive problem trying to sort dates.
i want to know what field type i should put the date as in my table.
also how to input a date into the table correctly. do i just do it as the date should look? or does it need to be converted into something like timestamp.
It depends what you will be using the date column for. The one I use most often is datetime.
Then you just format your variable to match when you insert it into the table.
If you're just storing dates, store it as a "date" type. And if you're using php to generate the date to input, the correct format is
date("Y-m-d");
im using it as the date of a gig for my band. then i want it to list all the gigs and sort them in date order.
so the date format whould be:
21/11/2003 for example.
Then use a date field.
and how do i insert it into the table in the correct format?
$sql = "INSERT INTO table (date_field) VALUES ('".date("Y-m-d")."')"; mysql_query($sql);
yes thats all very dandy.
but the dates are back to front.
2003-11-25
if insert them into the table the other way. they all fuk up.
how do i fix this?
and using date() is useless. coz that just shows todays date.
If you want to re-arrange it when you pull it, all you have to do is
date("m/d/Y", strtotime($rowFromDatabase));
wooooooooooo
thank you