I am creating a mysql db with a php frontend. The data it will use is extracted from another larger db and contains a date/time field which looks like this – 20120301073136 – which records when an event happened.
I understand that this might be a UNIX timestamp? Not sure.
I want to be show this field in the tables in my PHP webpage as a readable date and time –
ie something like 01-Mar-2012 07:31:36 or similar
Should I try and convert it with SQL command or let PHP format it? And, what is the code to do so?
BTW, it is important that I can sort the data (in SQL and in the PHP table) into date order – ie in the order that these events happened.
Thanks in advance for your help – Ive learnt a lot here already
J
You can convert it to a
datetimedirectly in your SQL query. Example:You can also order that with no need to convert it since it is a number in the format
YYYYMMDDHHmmss