Is it possible to format a date to just show the day of the week, e.g. Mon, from a string which is only the date of the format yyyy-mm-dd? DATE_FORMAT requires a timestamp as well as the date and the feed I’m using only delivers the date.
echo date('D', strtotime('2012-01-23'));
Edit:
Or in MySQL:
SELECT DATE_FORMAT('2012-01-23', '%a');
Thanks for your reply. I’m using a data feed which delivers future dates in the format yyyy-mm-dd, so I can’t use the date() function. However in looking up strtotime I found date_create which worked.
$day = date_create($date);
$day = DATE_FORMAT($day,'D');
echo $day;
Isn’t the format YYYY-MM-DD meant to be 2012-01-23? Is it something different ? Can you show us the date string as an example that comes in your feed?
2012-01-24
Then the following works with me here:
echo date('D', strtotime('2012-01-24'));
Prints ‘Tue’.
yep, you’re right, that works as well. I’m using a variable in a foreach loop so…
echo date('D', strtotime($date))