I have a set of date strings in the following format:
$date = 'month_name DD, YYYY';
What I would like to do is shorten the month name to 3 characters and remove the year from the end like this:
$output = 'June 10, 2012';
print $output // Outputs 'Jun 10';
So far I have the following, but have not been able to find a method to shorten the first word:
print substr($date, 0, strrpos($date, ',')); // Outputs 'June 10';
Any help would be appreciated!
Use PHP’s DateTime class:
This is a very stable way to convert times between different formats.
Demo