I think this is a simple question. We have a MySQL database with a DATE field, the date is stored in US format (2010-06-01).
In my PHP page where I’ll display the date, I simply want to convert this date into a UK format (01-06-2010).
Any help and advice appreciated!
Thanks,
Homer.
You didn’t specify and your example is ambiguous, but I’ll assume you’re talking about outputting in day-month-year format. You can use
strtotimeto parse a string date into a unix timestamp, and then give that timestamp todatealong with the format that you’d like to output your date in:The manual page for
datelists all the formatting options that you can give. In this case,drepresents the day as a zero-padded number,mrepresents the month as a zero-padded number, andYrepresents the year as a four digit number. Any characters that don’t have a specific meaning fordatecome across as-is.