Symfony Date Transformer

时间:2016-11-21 08:51:24

标签: php symfony symfony-3.1

使用php扩展Intl在DateTimeToLocalizedStringTransformer.php中形成一些日期时出现问题, 它取决于指定的date.timezone(这里例如欧洲/马耳他)

<?php

$begin = new DateTime( '1900-01-01' );
$end = new DateTime( '2100-01-01' );

$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);

$intlDateFormatter = new IntlDateFormatter("en_US", 2, -1, "Europe/Malta", 1, "dd/MM/yyyy");
$intlDateFormatter->setLenient(false);

foreach ( $period as $dt ){

    $test_date = $dt->format("d/m/Y");
    $timestamp = $intlDateFormatter->parse($test_date);

    if (intl_get_error_code() != 0) {
        echo $test_date."n";
        echo intl_get_error_message()."n";
    }

}

?>

此回报:

03/06/1916
Date parsing failed: U_PARSE_ERROR
01/04/1917
Date parsing failed: U_PARSE_ERROR
10/03/1918
Date parsing failed: U_PARSE_ERROR
02/03/1919
Date parsing failed: U_PARSE_ERROR
21/03/1920
Date parsing failed: U_PARSE_ERROR
15/06/1940
Date parsing failed: U_PARSE_ERROR
16/03/1947
Date parsing failed: U_PARSE_ERROR
22/05/1966
Date parsing failed: U_PARSE_ERROR
28/05/1967
Date parsing failed: U_PARSE_ERROR
26/05/1968
Date parsing failed: U_PARSE_ERROR
01/06/1969
Date parsing failed: U_PARSE_ERROR
31/05/1970
Date parsing failed: U_PARSE_ERROR
23/05/1971
Date parsing failed: U_PARSE_ERROR
28/05/1972
Date parsing failed: U_PARSE_ERROR
31/03/1973
Date parsing failed: U_PARSE_ERROR
21/04/1974
Date parsing failed: U_PARSE_ERROR

这与symfony没有直接关联,但在symfony中使用functionnality来转换日期。那么我们可以改变下一版symfony的功能吗?

0 个答案:

没有答案