Sometimes you need to change the format of a date that is in text format. For instance, I recently needed to take a text string containing the date and time of an event, and only display the date part. As the text string was originally generated using the PHP date function, it was easy to do this with a combination of strtotime and date.
The text string was originally generated like this:
$date = date("F j, Y, g:i a");
I stripped out the time part as follows:
$ts = strtotime($date); $date = date('F j, Y', $ts);
This left me with just the date.