Forum Moderators: coopster
I want to be able to insert stuff into a database, thats fine yeah, but how would I go about sorting it by the date it was submitted?
I am in the UK where the date format is DD/MM/YYYY and not MM/DD/YYYY, I know that mysql takes the date in the US format of MM/DD/YYYY, is there anyway to change this and successfully sort the data by the date it was submitted, e.g. have the oldest at the bottom and newest at the top?
any ideas, help or references would be appreciated.
Thanks
Chris
for example:
SELECT stuff, DATE_FORMAT(submitted_date, '%d/%m/%Y') AS uk_date FROM mytable ORDER BY submitted_date DESC;
note: as of mysql 5.1 there are some changes you should be aware of regarding language, character set and collation sequence for date_format() results.
just store a timestamp, you can then sort easily and can format it however you like for display
the timestamp column will typically update whenever an insert or update occurs.
this is the easy way to track the last change.
to specifically control the submitted date, you should use a datetime column and mktime() function on insert as camilord pointed out.