PHP change date format string using the following short function, use it wisely.

PHP change date format

This is one of those things that I ended up needing again and again, so it made sense to put it into a post.

function switch_date_format($dateString) {
  if (!empty($dateString)) {
    $myDateTime = DateTime::createFromFormat('m/d/Y', $dateString);
    $newDateString = $myDateTime->format('F m, Y');
    return $newDateString;
    return "";

If you are looking for how to amtch you custom date strings the php date manual page.

If you are looking for something similar but for Android/ Java see my post Android change date format from UTC to local time.

Let me know you found it useful.