The DateTimeInterface interface
(PHP 5 >= 5.5.0)
Introduction
Class synopsis
DateTimeInterface
{
/* Methods */
}Table of Contents
- DateTime::diff — Returns the difference between two DateTime objects
- DateTime::format — Returns date formatted according to given format
- DateTime::getOffset — Returns the timezone offset
- DateTime::getTimestamp — Gets the Unix timestamp
- DateTime::getTimezone — Return time zone relative to given DateTime
- DateTime::__wakeup — The __wakeup handler
Коментарии
Please note that if you are using DATE_RFC7231 format (used in HTTP/1.1), you'll need to change the DateTime object timezone to GMT *before*, or you'll encounter weird results, as this format DOES NOT convert the date to GMT.
So if you have a DateTime object using UTC+01:00 as its timezone, you will get a difference of 1 hour between your resulting date string and what should be the "correct" date.
Recommended use:
<?php
$date_gmt = clone $date;
$date_gmt->setTimezone(new \DateTimeZone('GMT'));
echo $date_gmt->format(DATE_RFC7231);
?>