Содержание
The DateTimeImmutable class
This class behaves the same as DateTime except new objects are returned when modification methods such as DateTime::modify() are called.
Class synopsis
public static createFromFormat ( string $format , string $datetime , ? DateTimeZone $timezone = null ): DateTimeImmutable | false
public setTime (
int $hour ,
int $minute ,
int $second = 0 ,
int $microsecond = 0
): DateTimeImmutable
Changelog
Version | Description |
---|---|
7.1.0 | The DateTimeImmutable constructor now includes the current microseconds in the constructed value. Before this, it would always initialise the microseconds to 0 . |
Table of Contents
- DateTimeImmutable::add — Returns a new object, with added amount of days, months, years, hours, minutes and seconds
- DateTimeImmutable::__construct — Returns new DateTimeImmutable object
- DateTimeImmutable::createFromFormat — Parses a time string according to a specified format
- DateTimeImmutable::createFromInterface — Returns new DateTimeImmutable object encapsulating the given DateTimeInterface object
- DateTimeImmutable::createFromMutable — Returns new DateTimeImmutable instance encapsulating the given DateTime object
- DateTimeImmutable::getLastErrors — Returns the warnings and errors
- DateTimeImmutable::modify — Creates a new object with modified timestamp
- DateTimeImmutable::__set_state — The __set_state handler
- DateTimeImmutable::setDate — Sets the date
- DateTimeImmutable::setISODate — Sets the ISO date
- DateTimeImmutable::setTime — Sets the time
- DateTimeImmutable::setTimestamp — Sets the date and time based on a Unix timestamp
- DateTimeImmutable::setTimezone — Sets the time zone
- DateTimeImmutable::sub — Subtracts an amount of days, months, years, hours, minutes and seconds
The DateTimeImmutable class
This class behaves the same as DateTime except new objects are returned when modification methods such as DateTime::modify() are called.
Class synopsis
public static createFromFormat ( string $format , string $datetime , ? DateTimeZone $timezone = null ): DateTimeImmutable | false
public setTime (
int $hour ,
int $minute ,
int $second = 0 ,
int $microsecond = 0
): DateTimeImmutable
Changelog
Version | Description |
---|---|
7.1.0 | The DateTimeImmutable constructor now includes the current microseconds in the constructed value. Before this, it would always initialise the microseconds to 0 . |
Table of Contents
- DateTimeImmutable::add — Returns a new object, with added amount of days, months, years, hours, minutes and seconds
- DateTimeImmutable::__construct — Returns new DateTimeImmutable object
- DateTimeImmutable::createFromFormat — Parses a time string according to a specified format
- DateTimeImmutable::createFromInterface — Returns new DateTimeImmutable object encapsulating the given DateTimeInterface object
- DateTimeImmutable::createFromMutable — Returns new DateTimeImmutable instance encapsulating the given DateTime object
- DateTimeImmutable::getLastErrors — Returns the warnings and errors
- DateTimeImmutable::modify — Creates a new object with modified timestamp
- DateTimeImmutable::__set_state — The __set_state handler
- DateTimeImmutable::setDate — Sets the date
- DateTimeImmutable::setISODate — Sets the ISO date
- DateTimeImmutable::setTime — Sets the time
- DateTimeImmutable::setTimestamp — Sets the date and time based on a Unix timestamp
- DateTimeImmutable::setTimezone — Sets the time zone
- DateTimeImmutable::sub — Subtracts an amount of days, months, years, hours, minutes and seconds
User Contributed Notes
- Date/Time
- Introduction
- Installing/Configuring
- Predefined Constants
- Examples
- DateTime
- DateTimeImmutable
- DateTimeInterface
- DateTimeZone
- DateInterval
- DatePeriod
- Date/Time Functions
- Supported Date and Time Formats
- List of Supported Timezones