添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Authentication Services
Command Line Specific Extensions
Compression and Archive Extensions
Cryptography Extensions
Database Extensions
Date and Time Related Extensions
File System Related Extensions
Human Language and Character Encoding Support
Image Processing and Generation
Mail Related Extensions
Mathematical Extensions
Non-Text MIME Output
Process Control Extensions
Other Basic Extensions
Other Services
Search Engine Extensions
Server Specific Extensions
Session Extensions
Text Processing
Variable and Type Related Extensions
Web Services
Windows Only Extensions
XML Manipulation
GUI Extensions
Keyboard Shortcuts
?
This help
Next menu item
Previous menu item
Previous man page
Next man page
Scroll to bottom
Scroll to top
Goto homepage
Goto search
(current page)
Focus search box
DateTimeImmutable DateTime を引数や戻り値、プロパティの型宣言で使えるようにするために作られたものです。 このインターフェイスを実装したクラスをユーザー側で作ることはできません。 DateTimeImmutable::format() DateTime::format() を通じて、 DateTimeImmutable DateTime をフォーマットするための共通の定数も、 このインターフェイスに定義されています。
/* メソッド */
public diff ( DateTimeInterface $targetObject , bool $absolute = false ): DateInterval
public format ( string $format ): string
ISO-8601 と互換性を保つためには、 DateTimeInterface::ISO8601_EXPANDED , DateTimeInterface::ATOM を使うようにしてください。 (ISO8601:2004 section 4.3.3 clause d も参照ください)

目次

Improve This Page

bohwaz
1 year ago
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 );
?>