Date::convertTo: Bitrix method

      
<?php 
//  Bitrix\Bizproc\BaseType\Date :: convertTo()
//  /dist/bitrix/modules/bizproc/lib/basetype/date.php:49

    
public static function convertTo(FieldType $fieldType$value$toTypeClass)
    {
        
/** @var Base $toTypeClass */
        
$type $toTypeClass::getType();
        switch (
$type)
        {
            case 
FieldType::DOUBLE:
            case 
FieldType::INT:
                
$value $value? (int)strtotime($value) : 0;
                break;
            case 
FieldType::DATE:
            case 
FieldType::DATETIME:
            case 
FieldType::STRING:
            case 
FieldType::TEXT:
                
$value = (string) $value;
                if (
$value)
                {
                    if (
$type == FieldType::DATE)
                        
$format = \FORMAT_DATE;
                    elseif (
$type == FieldType::DATETIME)
                        
$format = \FORMAT_DATETIME;
                    else
                        
$format = static::getType() == FieldType::DATE ? \FORMAT_DATE : \FORMAT_DATETIME;

                    if (\
CheckDateTime($value$format))
                    {
                        
$value date(Type\Date::convertFormatToPhp($format), \MakeTimeStamp($value$format));
                    }
                    else
                    {
                        
$value date(Type\Date::convertFormatToPhp($format), strtotime($value));
                    }
                }
                break;
            default:
                
$value null;
        }

        return 
$value;
    }