src/Components/Schema.php
public static function formatDateTime($out_format, $in_format, $value = null)
    {
        if (!empty($out_format) && !empty($in_format)) {
            $value = (is_string($value) || is_null($value)) ? $value : strval($value);
            if (!empty($value)) {
                if (false === $date = \DateTime::createFromFormat($in_format, $value)) {
                    \Log::error("Failed to create datetime with '$value' as format '$in_format'");
                    try {
                        $date = new \DateTime($value);
                    } catch (\Exception $e) {
                        \Log::error("Failed to create datetime from '$value': " . $e->getMessage());

                        return $value;
                    }
                }
            } else {
                //  If value is null, current date and time are returned
                try {
                    $date = new \DateTime();
                } catch (\Exception $e) {
                    \Log::error("Failed to create current datetime: " . $e->getMessage());

                    return $value;
                }
            }

            return $date->format($out_format);
        }

        return $value;
    }
public static function formatDateTime($out_format, $in_format, $value = null)
    {
        if (!empty($out_format) && !empty($in_format)) {
            $value = (is_string($value) || is_null($value)) ? $value : strval($value);
            if (!empty($value)) {
                if (false === $date = \DateTime::createFromFormat($in_format, $value)) {
                    \Log::error("Failed to create datetime with '$value' as format '$in_format'");
                    try {
                        $date = new \DateTime($value);
                    } catch (\Exception $e) {
                        \Log::error("Failed to create datetime from '$value': " . $e->getMessage());

                        return $value;
                    }
                }
            } else {
                //  If value is null, current date and time are returned
                try {
                    $date = new \DateTime();
                } catch (\Exception $e) {
                    \Log::error("Failed to create current datetime: " . $e->getMessage());

                    return $value;
                }
            }

            return $date->format($out_format);
        }

        return $value;
    }
@param string $out_format
@param string $in_format
@param mixed $value

@return null|string