public static function convertToDatetime($rawDate, $format = 'd.m.Y')
    {
        // convert timestamp to date format
        if (Any::isInt($rawDate)) {
            $rawDate = date(\DateTime::ATOM, $rawDate);
        }

        try {
            $object = new \DateTime($rawDate);
            return $object->format($format);
        } catch (\Exception $e) {
            return false;
        }
    }
public static function convertToDatetime($rawDate, $format = 'd.m.Y')
    {
        // convert timestamp to date format
        if (Any::isInt($rawDate)) {
            $rawDate = date(\DateTime::ATOM, $rawDate);
        }

        try {
            $object = new \DateTime($rawDate);
            return $object->format($format);
        } catch (\Exception $e) {
            return false;
        }
    }
public static function convertToDatetime ( $ rawDate , $ format = 'd.m.Y' ) { // convert timestamp to date format if ( Any :: isInt ( $ rawDate ) ) { $ rawDate = date ( \ DateTime :: ATOM , $ rawDate ) ; } try { $ object = new \ DateTime ( $ rawDate ) ; return $ object -> format ( $ format ) ; } catch ( \ Exception $ e ) { return false ; } }
Try to convert string to date time format
@param string|int $rawDate
@param string $format
@return string|bool
Try to convert string to date time format