PHP不显示UTC Z TimeZone指示符

时间:2011-11-28 17:37:23

标签: php utc datetimeoffset

当我尝试将日期格式化为UTC时,它不会显示UTC zero timezone designator的'z'。这是图书馆的问题吗?

# Define Some date
$scheduledDate = "2011-11-23T10:25:00";
echo $scheduledDate . "\n";

# Convert to DateTime object    
$startTime = DateTime::createFromFormat('Y-m-d\TH:i:s', $scheduledDate);    
print_r($startTime) ;

# Verify Time Zone
$sDate = $startTime -> format(DateTime::ATOM);
echo "\nAtom Date:\t" . $sDate . "\n";

# Convert to UTC time
$startTimestr =  strtotime ($startTime -> format(DateTime::ATOM));
echo "epoch Time:\t" . $startTimestr . "\n";

# Print Different Formats   
$gmDate = gmdate(DateTime::ATOM , $startTimestr);
echo "ATOM:\t\t" . $gmDate . "\n";
$gmDate = gmdate(DateTime::ISO8601 , $startTimestr);
echo "ISO8601:\t" . $gmDate . "\n";
$gmDate = gmdate(DateTime::RFC3339 , $startTimestr);
echo "RFC3339:\t" . $gmDate . "\n";
$gmDate = gmdate(DateTime::W3C , $startTimestr);
echo "W3C:\t\t" . $gmDate . "\n";

结果如下:

2011-11-23T10:25:00

DateTime Object
(
    [date] => 2011-11-23 10:25:00
    [timezone_type] => 3
    [timezone] => America/Denver
)

Atom Date:  2011-11-23T10:25:00-07:00
epoch Time: 1322069100
ATOM:       2011-11-23T17:25:00+00:00
ISO8601:    2011-11-23T17:25:00+0000
RFC3339:    2011-11-23T17:25:00+00:00
W3C:        2011-11-23T17:25:00+00:00

请注意,没有一种格式具有z。我原以为

Atom Date:  2011-11-23T10:25:00-07:00
epoch Time: 1322069100
ATOM:       2011-11-23T17:25:00z
ISO8601:    2011-11-23T17:25:00z
RFC3339:    2011-11-23T17:25:00z
W3C:        2011-11-23T17:25:00z

0 个答案:

没有答案