I have an sql database with a date column like this yyyymmdd (20111109), i usually sort my return queries by the date.
I would like to know how to convert this to the (D jS M) or (Wed 9th Nov).
For the month, date, and ordinal suffix, im using substr along with case. but its the weekday im getting frustrated with.
Is there a simpler method?
Thanks in advance.
If you are interested in something more sophisticated:
$date = DateTime::createFromFormat('Ymd', '20111109');
echo $date->format('D jS M');
This should be more reliable in the long run.
This should work:
date_default_timezone_set('America/Los_Angeles');
$date = strtotime($your_string);
$formatted_date = date('D jS M', $date);
echo $formatted_date;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With