code: public static function convertDate($dateString, $fromFormat, $toFormat)
      {
          $date = DateTime::createFromFormat($fromFormat, $dateString);
          if (!$date && $fromFormat == DateFormat::FORMAT_ORACLE_WITH_MICROSECONDS) {
              $date = DateTime::createFromFormat(DateFormat::FORMAT_ORACLE_DATE_ONLY, $dateString);
          }
  
          if ($date) {
              return $date->format($toFormat);
          }
          return $dateString;
      }
docs: Converts a datetime string from one format to another format
  @author Adegoke Obasa <goke@cottacush.com>
  @param $dateString
  @param $fromFormat
  @param $toFormat
  @return string