1

When I try to format a date to UTC, It doesn't show the 'z' for the UTC zero timezone designator. Is this a problem with the library?

# 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";

The Results looks like:

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

Notice that none of the formats have z. I would have expected

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
4

0 回答 0