public static function convertDateFromYMD($date, $secondaryDate = null) { if (empty($date)) { return ''; } if (ClassicValidator::checkDateRegexYMD($date)) { list($year, $month, $day) = explode('-', $date); try { $rightDate = self::convertMonth($month) . ' ' . $day . ', ' . $year; } catch (\Exception $ex) { $rightDate = $secondaryDate; } return $rightDate; } else { throw new \Exception('Invalid date format.'); } }