日付・時刻

目次

DateTime クラス

はじめに

日付と時刻を表現するクラスです。

このクラスは、 DateTimeImmutable と同じ振る舞いをします。 但し、DateTime::modify のような、 オブジェクトそのものを変更するメソッドが呼び出された時を除きます。

警告

DateTime クラスのメソッドをコールすると、 そのインスタンスにカプセル化された情報が変更されます。 そうした変更を防ぎたい場合には、新しいオブジェクトを作るために clone 演算子を使わなければいけません。 オブジェクトの変更を防ぐ、望ましい挙動をデフォルトで実現するには、 DateTime ではなく、 DateTimeImmutable を使います。

クラス概要

DateTime
implements DateTimeInterface
/* 継承した定数 */
public const string DateTimeInterface::ATOM = "Y-m-d\\TH:i:sP";
public const string DateTimeInterface::COOKIE = "l, d-M-Y H:i:s T";
public const string DateTimeInterface::ISO8601 = "Y-m-d\\TH:i:sO";
public const string DateTimeInterface::ISO8601_EXPANDED = "X-m-d\\TH:i:sP";
public const string DateTimeInterface::RFC822 = "D, d M y H:i:s O";
public const string DateTimeInterface::RFC850 = "l, d-M-y H:i:s T";
public const string DateTimeInterface::RFC1036 = "D, d M y H:i:s O";
public const string DateTimeInterface::RFC1123 = "D, d M Y H:i:s O";
public const string DateTimeInterface::RFC7231 = "D, d M Y H:i:s \\G\\M\\T";
public const string DateTimeInterface::RFC2822 = "D, d M Y H:i:s O";
public const string DateTimeInterface::RFC3339 = "Y-m-d\\TH:i:sP";
public const string DateTimeInterface::RFC3339_EXTENDED = "Y-m-d\\TH:i:s.vP";
public const string DateTimeInterface::RSS = "D, d M Y H:i:s O";
public const string DateTimeInterface::W3C = "Y-m-d\\TH:i:sP";
/* メソッド */
public __construct(string $datetime = "now", DateTimeZonenull $timezone = null)
public DateTime add(DateInterval $interval)
public static DateTimefalse createFromFormat(string $format, string $datetime, DateTimeZonenull $timezone = null)
public static static createFromImmutable(DateTimeImmutable $object)
public static DateTime createFromInterface(DateTimeInterface $object)
public DateTimefalse modify(string $modifier)
public static DateTime __set_state(array $array)
public DateTime setDate(int $year, int $month, int $day)
public DateTime setISODate(int $year, int $week, int $dayOfWeek = 1)
public DateTime setTime(
    int $hour,
    int $minute,
    int $second = 0,
    int $microsecond = 0
)
public DateTime setTimestamp(int $timestamp)
public DateTime setTimezone(DateTimeZone $timezone)
public DateTime sub(DateInterval $interval)
public DateInterval diff(DateTimeInterface $targetObject, bool $absolute = false)
public string format(string $format)
public int getOffset()
public int getTimestamp()
public DateTimeZonefalse getTimezone()
public void __wakeup()

変更履歴

バージョン 説明
7.2.0 DateTime クラスの定数は、 DateTimeInterface で定義されるようになりました。
7.1.0 DateTime のコンストラクタで構築される値に、 現在時刻のマイクロ秒が含まれるようになりました。 これより前のバージョンでは、このマイクロ秒の情報は常に 0 で初期化されていました。

DateTimeImmutable クラス

はじめに

日付と時刻を表現します。

このクラスは DateTime と同じ振る舞いをします。 但し、DateTime::modify のような、 状態を変更して新しいオブジェクトを返すメソッドが呼び出された時を除きます。

クラス概要

DateTimeImmutable
implements DateTimeInterface
/* 継承した定数 */
public const string DateTimeInterface::ATOM = "Y-m-d\\TH:i:sP";
public const string DateTimeInterface::COOKIE = "l, d-M-Y H:i:s T";
public const string DateTimeInterface::ISO8601 = "Y-m-d\\TH:i:sO";
public const string DateTimeInterface::ISO8601_EXPANDED = "X-m-d\\TH:i:sP";
public const string DateTimeInterface::RFC822 = "D, d M y H:i:s O";
public const string DateTimeInterface::RFC850 = "l, d-M-y H:i:s T";
public const string DateTimeInterface::RFC1036 = "D, d M y H:i:s O";
public const string DateTimeInterface::RFC1123 = "D, d M Y H:i:s O";
public const string DateTimeInterface::RFC7231 = "D, d M Y H:i:s \\G\\M\\T";
public const string DateTimeInterface::RFC2822 = "D, d M Y H:i:s O";
public const string DateTimeInterface::RFC3339 = "Y-m-d\\TH:i:sP";
public const string DateTimeInterface::RFC3339_EXTENDED = "Y-m-d\\TH:i:s.vP";
public const string DateTimeInterface::RSS = "D, d M Y H:i:s O";
public const string DateTimeInterface::W3C = "Y-m-d\\TH:i:sP";
/* メソッド */
public __construct(string $datetime = "now", DateTimeZonenull $timezone = null)
public DateTimeImmutable add(DateInterval $interval)
public static DateTimeImmutablefalse createFromFormat(string $format, string $datetime, DateTimeZonenull $timezone = null)
public static DateTimeImmutable createFromInterface(DateTimeInterface $object)
public static static createFromMutable(DateTime $object)
public static arrayfalse getLastErrors()
public DateTimeImmutablefalse modify(string $modifier)
public static DateTimeImmutable __set_state(array $array)
public DateTimeImmutable setDate(int $year, int $month, int $day)
public DateTimeImmutable setISODate(int $year, int $week, int $dayOfWeek = 1)
public DateTimeImmutable setTime(
    int $hour,
    int $minute,
    int $second = 0,
    int $microsecond = 0
)
public DateTimeImmutable setTimestamp(int $timestamp)
public DateTimeImmutable setTimezone(DateTimeZone $timezone)
public DateTimeImmutable sub(DateInterval $interval)
public DateInterval diff(DateTimeInterface $targetObject, bool $absolute = false)
public string format(string $format)
public int getOffset()
public int getTimestamp()
public DateTimeZonefalse getTimezone()
public void __wakeup()

変更履歴

バージョン 説明
7.1.0 DateTimeImmutable のコンストラクタで構築される値に、 現在時刻のマイクロ秒が含まれるようになりました。 これより前のバージョンでは、このマイクロ秒の情報は常に 0 で初期化されていました。

DateTimeInterface インターフェイス

はじめに

DateTimeInterface は、 DateTimeImmutableDateTime を引数や戻り値、プロパティの型宣言で使えるようにするために作られたものです。 このインターフェイスを実装したクラスをユーザー側で作ることはできません。

DateTimeImmutable::formatDateTime::format を通じて、 DateTimeImmutableDateTime をフォーマットするための共通の定数も、 このインターフェイスに定義されています。

インターフェイス概要

DateTimeInterface
/* 定数 */
public const string DateTimeInterface::ATOM = "Y-m-d\\TH:i:sP";
public const string DateTimeInterface::COOKIE = "l, d-M-Y H:i:s T";
public const string DateTimeInterface::ISO8601 = "Y-m-d\\TH:i:sO";
public const string DateTimeInterface::ISO8601_EXPANDED = "X-m-d\\TH:i:sP";
public const string DateTimeInterface::RFC822 = "D, d M y H:i:s O";
public const string DateTimeInterface::RFC850 = "l, d-M-y H:i:s T";
public const string DateTimeInterface::RFC1036 = "D, d M y H:i:s O";
public const string DateTimeInterface::RFC1123 = "D, d M Y H:i:s O";
public const string DateTimeInterface::RFC7231 = "D, d M Y H:i:s \\G\\M\\T";
public const string DateTimeInterface::RFC2822 = "D, d M Y H:i:s O";
public const string DateTimeInterface::RFC3339 = "Y-m-d\\TH:i:sP";
public const string DateTimeInterface::RFC3339_EXTENDED = "Y-m-d\\TH:i:s.vP";
public const string DateTimeInterface::RSS = "D, d M Y H:i:s O";
public const string DateTimeInterface::W3C = "Y-m-d\\TH:i:sP";
/* メソッド */
public DateInterval DateTimeInterface::diff(DateTimeInterface $targetObject, bool $absolute = false)
public string DateTimeInterface::format(string $format)
public int DateTimeInterface::getOffset()
public int DateTimeInterface::getTimestamp()
public DateTimeZonefalse DateTimeInterface::getTimezone()
public void DateTimeInterface::__wakeup()

定義済み定数

DateTimeInterface::ATOM
DATE_ATOM
Atom (例: 2005-08-15T15:52:01+00:00)
DateTimeInterface::COOKIE
DATE_COOKIE
HTTP Cookie (例: Monday, 15-Aug-2005 15:52:01 UTC)
DateTimeInterface::ISO8601
DATE_ISO8601
ISO-8601 (例: 2005-08-15T15:52:01+0000)

注意: このフォーマットは、ISO-8601 と互換性がありません。 しかし、後方互換性を保つために残されています。 ISO-8601 と互換性を保つためには、 DateTimeInterface::ISO8601_EXPANDED, DateTimeInterface::ATOM を使うようにしてください。 (ISO8601:2004 section 4.3.3 clause d も参照ください)

DateTimeInterface::ISO8601_EXPANDED
DATE_ISO8601_EXPANDED
ISO-8601 拡張形式 (例: +10191-07-26T08:59:52+01:00)

注意: 年に常に符号を含めることで、ISO-8601 の通常の範囲 0000-9999 以外の値が許されています。 タイムゾーンの部分 (+01:00) については、 ISO-8601 と互換性をとるようにもなっています。

DateTimeInterface::RFC822
DATE_RFC822
RFC 822 (例: Mon, 15 Aug 05 15:52:01 +0000)
DateTimeInterface::RFC850
DATE_RFC850
RFC 850 (例: Monday, 15-Aug-05 15:52:01 UTC)
DateTimeInterface::RFC1036
DATE_RFC1036
RFC 1036 (例: Mon, 15 Aug 05 15:52:01 +0000)
DateTimeInterface::RFC1123
DATE_RFC1123
RFC 1123 (例: Mon, 15 Aug 2005 15:52:01 +0000)
DateTimeInterface::RFC7231
DATE_RFC7231
RFC 7231 (PHP 7.0.19 と 7.1.5以降) (例: Sat, 30 Apr 2016 17:52:13 GMT)
DateTimeInterface::RFC2822
DATE_RFC2822
RFC 2822 (例: Mon, 15 Aug 2005 15:52:01 +0000)
DateTimeInterface::RFC3339
DATE_RFC3339
DATE_ATOM と同じです
DateTimeInterface::RFC3339_EXTENDED
DATE_RFC3339_EXTENDED
RFC 3339 EXTENDED フォーマット (例: 2005-08-15T15:52:01.000+00:00)
DateTimeInterface::RSS
DATE_RSS
RSS (例: Mon, 15 Aug 2005 15:52:01 +0000)
DateTimeInterface::W3C
DATE_W3C
World Wide Web Consortium (例: 2005-08-15T15:52:01+00:00)

変更履歴

バージョン 説明
8.2.0 定数 DateTimeInterface::ISO8601_EXPANDED が追加されました。
7.2.0 DateTime クラスの定数は、 DateTimeInterface で定義されるようになりました。

DateTimeZone クラス

はじめに

タイムゾーンをあらわします。

クラス概要

DateTimeZone
/* 定数 */
public const int DateTimeZone::AFRICA;
public const int DateTimeZone::AMERICA;
public const int DateTimeZone::ANTARCTICA;
public const int DateTimeZone::ARCTIC;
public const int DateTimeZone::ASIA;
public const int DateTimeZone::ATLANTIC;
public const int DateTimeZone::AUSTRALIA;
public const int DateTimeZone::EUROPE;
public const int DateTimeZone::INDIAN;
public const int DateTimeZone::PACIFIC;
public const int DateTimeZone::UTC;
public const int DateTimeZone::ALL;
public const int DateTimeZone::ALL_WITH_BC;
public const int DateTimeZone::PER_COUNTRY;
/* メソッド */
public __construct(string $timezone)
public arrayfalse getLocation()
public string getName()
public int getOffset(DateTimeInterface $datetime)
public arrayfalse getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX)
public static array listAbbreviations()
public static array listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, stringnull $countryCode = null)

定義済み定数

DateTimeZone::AFRICA

アフリカのタイムゾーン。

DateTimeZone::AMERICA

アメリカのタイムゾーン。

DateTimeZone::ANTARCTICA

南極のタイムゾーン。

DateTimeZone::ARCTIC

北極のタイムゾーン。

DateTimeZone::ASIA

アジアのタイムゾーン。

DateTimeZone::ATLANTIC

大西洋のタイムゾーン。

DateTimeZone::AUSTRALIA

オーストラリアのタイムゾーン。

DateTimeZone::EUROPE

ヨーロッパのタイムゾーン。

DateTimeZone::INDIAN

インドのタイムゾーン。

DateTimeZone::PACIFIC

太平洋のタイムゾーン。

DateTimeZone::UTC

UTC タイムゾーン。

DateTimeZone::ALL

すべてのタイムゾーン。

DateTimeZone::ALL_WITH_BC

過去との互換性を保つものを含むすべてのタイムゾーン。

DateTimeZone::PER_COUNTRY

国ごとのタイムゾーン。

DateInterval クラス

はじめに

日付の間隔をあらわします。

格納方式は、固定値 (年、月、日、時など) あるいは相対時刻 (DateTimeImmutableDateTime のコンストラクタがサポートしている書式) となります。

さらに厳密に言うと、 DateInterval オブジェクトが保持している情報は、 ある date/time オブジェクトから別の date/time オブジェクトに情報を移す手順です。 この過程は必ずしも可逆ではありません。

DateInterval オブジェクトを生成する一般的なやり方は、 2つの date/time オブジェクトの差分を DateTimeInterface::diff 経由で計算することです。

日付の間隔を比較する良い方法は定義されていません。 よって、DateInterval のインスタンスは 比較できません

クラス概要

DateInterval
/* プロパティ */
public int $y;
public int $m;
public int $d;
public int $h;
public int $i;
public int $s;
public float $f;
public int $invert;
public mixed $days;
public bool $from_string;
public string $date_string;
/* メソッド */
public __construct(string $duration)
public static DateIntervalfalse createFromDateString(string $datetime)
public string format(string $format)

プロパティ

警告

以下に示すプロパティが使えるかどうかは、 PHP のバージョンに依存します。 そして、readonly と見なすべきです。

y

年。

m

月。

d

日。

h

時間。

i

分。

s

秒。

f

マイクロ秒。1秒の100万分の1です。

invert

間隔が負の数になっている場合は 1、そうでない場合は 0DateInterval::format を参照ください。

days

DateTimeImmutable::diffDateTime::diff で作られた DateInterval オブジェクトの場合は、開始日と終了日の間の(丸一日、つまり0時から24時までの一日全体という意味での)日の数。 それ以外の場合は daysfalse となります。

from_string

DateInterval::createFromDateString で作られた DateInterval オブジェクトの場合は、 このプロパティの値は true になり、 date_string の値が収集されます。 そうでない場合、この値は false になり、 y, f, invert, days の値が収集されます。

date_string

DateInterval::createFromDateString の引数として使われる文字列。

変更履歴

バージョン 説明
8.2.0 DateInterval::createFromDateString で作られた DateInterval のインスタンスのために、 プロパティ from_stringdate_string が追加されました。
8.2.0 プロパティ y から f, invert, days のみがアクセス可能になりました。
7.4.0 DateInterval インスタンスは、 比較できなくなりました。 これより前のバージョンでは、 全ての DateInterval のインスタンスが等しいとみなされていました。
7.1.0 f プロパティが追加されました

DatePeriod クラス

はじめに

日付の期間をあらわします。

日付の期間を使うと、指定した期間に定期的に発生する内容を反復処理できます。

クラス概要

DatePeriod
implements IteratorAggregate
/* 定数 */
public const int DatePeriod::EXCLUDE_START_DATE;
public const int DatePeriod::INCLUDE_END_DATE;
/* プロパティ */
public readonly DateTimeInterfacenull $start;
public readonly DateTimeInterfacenull $current;
public readonly DateTimeInterfacenull $end;
public readonly DateIntervalnull $interval;
public readonly int $recurrences;
public readonly bool $include_start_date;
public readonly bool $include_end_date;
/* メソッド */
public __construct(
    DateTimeInterface $start,
    DateInterval $interval,
    int $recurrences,
    int $options = 0
)
public __construct(
    DateTimeInterface $start,
    DateInterval $interval,
    DateTimeInterface $end,
    int $options = 0
)
public __construct(string $isostr, int $options = 0)
public static static createFromISO8601String(string $specification, int $options = 0)
public DateInterval getDateInterval()
public DateTimeInterfacenull getEndDate()
public intnull getRecurrences()
public DateTimeInterface getStartDate()

定義済み定数

DatePeriod::EXCLUDE_START_DATE

開始日を含まない。DatePeriod::__construct で使用します。

DatePeriod::INCLUDE_END_DATE

終了日を含む。DatePeriod::__construct で使用します。

プロパティ

recurrences

イテレータが返す最小のインスタンスの数。

DatePeriod のコンストラクタの recurrences に繰り返しの回数を明示的に渡した場合、 このプロパティにはその値が含まれます。 DatePeriod::EXCLUDE_START_DATE によって開始日が無効にされていない場合、 このプロパティには それよりひとつ多い 値が設定されます。 DatePeriod::INCLUDE_END_DATE で終了日が有効になっている場合、 このプロパティには さらにひとつ多い 値が設定されます。

繰り返しの回数を明示的に渡さなかった場合、 このプロパティには返される最小のインスタンスの数が含まれます。 この値は 0 になるはずですが、 DatePeriod::EXCLUDE_START_DATE によって開始日が無効にされていない場合、 このプロパティには それよりひとつ多い 値が設定されます。 DatePeriod::INCLUDE_END_DATE で終了日が有効になっている場合、 このプロパティには さらにひとつ多い 値が設定されます。

<?php
$start 
= new DateTime('2018-12-31 00:00:00');
$end   = new DateTime('2021-12-31 00:00:00');
$interval = new DateInterval('P1M');
$recurrences 5;
// コンストラクタで明示的に繰り返し回数を設定
$period = new DatePeriod($start$interval$recurrencesDatePeriod::EXCLUDE_START_DATE);
echo 
$period->recurrences"\n";
$period = new DatePeriod($start$interval$recurrences);
echo 
$period->recurrences"\n";
$period = new DatePeriod($start$interval$recurrencesDatePeriod::INCLUDE_END_DATE);
echo 
$period->recurrences"\n";
// コンストラクタで繰り返し回数を設定しない場合
$period = new DatePeriod($start$interval$end);
echo 
$period->recurrences"\n";
$period = new DatePeriod($start$interval$endDatePeriod::EXCLUDE_START_DATE);
echo 
$period->recurrences"\n";
?>

上の例の出力は以下となります。


5
6
7
1
0

DatePeriod::getRecurrences もご覧ください。

include_end_date

終了日を反復日のセットに含めるかどうか。

include_start_date

開始日を反復日のセットに含めるかどうか。

start

期間の開始日。

current

反復中に期間内の現在の日付が含まれます。

end

期間の終了日。

interval

ISO 8601 の繰り返し間隔の指定。

変更履歴

バージョン 説明
8.2.0 定数 DatePeriod::INCLUDE_END_DATE と プロパティ include_end_date が追加されました。
8.0.0 DatePeriod は、 IteratorAggregate を実装するようになりました。 これより前のバージョンでは、 Traversable を実装していました。

DateError クラス

はじめに

タイムゾーンデータベースが見つからなかったり、不正なデータが含まれている場合にスローされます。

このエラーは決して発生しないはずです。 発生する場合、ユーザーが書いたコード以外が原因です。 このエラーには2つの子クラス(DateObjectErrorDateRangeError) があり、それらはプログラマーの間違いや期間に関する問題が原因でスローされます。

クラス概要

DateError
extends Error
/* 継承したプロパティ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private Throwablenull $previous = null;
/* 継承したメソッド */
public __construct(string $message = "", int $code = 0, Throwablenull $previous = null)
final public string getMessage()
final public Throwablenull getPrevious()
final public int getCode()
final public string getFile()
final public int getLine()
final public array getTrace()
final public string getTraceAsString()
public string __toString()
private void __clone()

参考

  • DateObjectError
  • DateRangeError

DateObjectError クラス

はじめに

日付/時刻に関するクラスが、正しく初期化されていない場合にスローされます。

日付/時刻に関するクラスには final が指定されていないので、継承可能です。 親クラスのコンストラクタがコールされない場合、このエラーがスローされます。 これは常に、プログラミング時の誤りです。

クラス概要

DateObjectError
extends DateError
/* 継承したプロパティ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private Throwablenull $previous = null;
/* 継承したメソッド */
public Error::__construct(string $message = "", int $code = 0, Throwablenull $previous = null)
final public string Error::getMessage()
final public Throwablenull Error::getPrevious()
final public int Error::getCode()
final public string Error::getFile()
final public int Error::getLine()
final public array Error::getTrace()
final public string Error::getTraceAsString()
public string Error::__toString()
private void Error::__clone()

参考

  • DateError
  • DateRangeError

DateRangeError クラス

はじめに

32ビットプラットフォーム上で、 日付オブジェクトが符号付き32ビットの範囲外の日付を表していた場合にスローされます。 このエラーをスローするのは、 DateTime::getTimestamp, DateTimeImmutable::getTimestamp, date_timestamp_get です。

クラス概要

DateRangeError
extends DateError
/* 継承したプロパティ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private Throwablenull $previous = null;
/* 継承したメソッド */
public Error::__construct(string $message = "", int $code = 0, Throwablenull $previous = null)
final public string Error::getMessage()
final public Throwablenull Error::getPrevious()
final public int Error::getCode()
final public string Error::getFile()
final public int Error::getLine()
final public array Error::getTrace()
final public string Error::getTraceAsString()
public string Error::__toString()
private void Error::__clone()

参考

  • DateError
  • DateObjectError

DateException クラス

はじめに

日付/時刻に関する例外の親クラスです。 ユーザーの入力や、パースが必要な自由入力のテキスト引数によって生じる問題に対応するものです。

以下の子クラスの例外がスローされます:

  • DateInvalidOperationException
  • DateInvalidTimezoneException
  • DateMalformedIntervalStringException
  • DateMalformedPeriodStringException
  • DateMalformedStringException

クラス概要

DateException
extends Exception
/* 継承したプロパティ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private Throwablenull $previous = null;
/* 継承したメソッド */
public __construct(string $message = "", int $code = 0, Throwablenull $previous = null)
final public string getMessage()
final public Throwablenull getPrevious()
final public int getCode()
final public string getFile()
final public int getLine()
final public array getTrace()
final public string getTraceAsString()
public string __toString()
private void __clone()

DateInvalidOperationException クラス

はじめに

サポートされていない操作が行われた場合に、 DateTimeImmutable::subDateTime::sub がスローします。

サポートされていない操作の例として、 next weekday のような相対時間を表現する DateInterval を使った場合が挙げられます。 サポートされない理由は、論理的に逆の式が構築できないからです。

クラス概要

DateInvalidOperationException
extends DateException
/* 継承したプロパティ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private Throwablenull $previous = null;
/* 継承したメソッド */
public Exception::__construct(string $message = "", int $code = 0, Throwablenull $previous = null)
final public string Exception::getMessage()
final public Throwablenull Exception::getPrevious()
final public int Exception::getCode()
final public string Exception::getFile()
final public int Exception::getLine()
final public array Exception::getTrace()
final public string Exception::getTraceAsString()
public string Exception::__toString()
private void Exception::__clone()

DateInvalidTimeZoneException クラス

はじめに

DateTimeZone::__construct に無効な値が渡された場合にスローされます。

クラス概要

DateInvalidTimeZoneException
extends DateException
/* 継承したプロパティ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private Throwablenull $previous = null;
/* 継承したメソッド */
public Exception::__construct(string $message = "", int $code = 0, Throwablenull $previous = null)
final public string Exception::getMessage()
final public Throwablenull Exception::getPrevious()
final public int Exception::getCode()
final public string Exception::getFile()
final public int Exception::getLine()
final public array Exception::getTrace()
final public string Exception::getTraceAsString()
public string Exception::__toString()
private void Exception::__clone()

DateMalformedIntervalStringException クラス

はじめに

DateInterval::__construct に無効な duration が渡された場合にスローされます。

クラス概要

DateMalformedIntervalStringException
extends DateException
/* 継承したプロパティ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private Throwablenull $previous = null;
/* 継承したメソッド */
public Exception::__construct(string $message = "", int $code = 0, Throwablenull $previous = null)
final public string Exception::getMessage()
final public Throwablenull Exception::getPrevious()
final public int Exception::getCode()
final public string Exception::getFile()
final public int Exception::getLine()
final public array Exception::getTrace()
final public string Exception::getTraceAsString()
public string Exception::__toString()
private void Exception::__clone()

DateMalformedPeriodStringException クラス

はじめに

DatePeriod::__construct に無効な isostr が渡された場合にスローされます。

クラス概要

DateMalformedPeriodStringException
extends DateException
/* 継承したプロパティ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private Throwablenull $previous = null;
/* 継承したメソッド */
public Exception::__construct(string $message = "", int $code = 0, Throwablenull $previous = null)
final public string Exception::getMessage()
final public Throwablenull Exception::getPrevious()
final public int Exception::getCode()
final public string Exception::getFile()
final public int Exception::getLine()
final public array Exception::getTrace()
final public string Exception::getTraceAsString()
public string Exception::__toString()
private void Exception::__clone()

DateMalformedStringException クラス

はじめに

無効な日付/時刻の文字列が検知された場合にスローされます。

これをスローする可能性があるのは DateTimeImmutable::__construct, DateTimeImmutable::modify, DateTime::__construct, DateTime::modify です。

クラス概要

DateMalformedStringException
extends DateException
/* 継承したプロパティ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private Throwablenull $previous = null;
/* 継承したメソッド */
public Exception::__construct(string $message = "", int $code = 0, Throwablenull $previous = null)
final public string Exception::getMessage()
final public Throwablenull Exception::getPrevious()
final public int Exception::getCode()
final public string Exception::getFile()
final public int Exception::getLine()
final public array Exception::getTrace()
final public string Exception::getTraceAsString()
public string Exception::__toString()
private void Exception::__clone()