The DateTimeImmutable class

(PHP 5 >= 5.5.0)

Introduction

This class behaves the same as DateTime except it never modifies itself but returns a new object instead.

Class synopsis

DateTimeImmutable implements DateTimeInterface {
/* Methods */
public __construct ([ string $time = "now" [, DateTimeZone $timezone = NULL ]] )
public DateTimeImmutable add ( DateInterval $interval )
public static DateTimeImmutable createFromFormat ( string $format , string $time [, DateTimeZone $timezone ] )
public static array getLastErrors ( void )
public DateTimeImmutable modify ( string $modify )
public static DateTimeImmutable __set_state ( array $array )
public DateTimeImmutable setDate ( int $year , int $month , int $day )
public DateTimeImmutable setISODate ( int $year , int $week [, int $day = 1 ] )
public DateTimeImmutable setTime ( int $hour , int $minute [, int $second = 0 ] )
public DateTimeImmutable setTimestamp ( int $unixtimestamp )
public DateTimeImmutable setTimezone ( DateTimeZone $timezone )
public DateTimeImmutable sub ( DateInterval $interval )
public DateInterval diff ( DateTimeInterface $datetime2 [, bool $absolute = false ] )
public string format ( string $format )
public int getOffset ( void )
public int getTimestamp ( void )
public DateTimeZone getTimezone ( void )
public __wakeup ( void )
}

Table of Contents

Коментарии

La diferencia entre esta clase (DateTimeInmutable), de DateTime, es que la instancia de esta clase no permite modificación, es decir, es inmutable. En caso de querer modificar la fecha con el método modify(), este devuelve un nuevo objeto. De esta forma al invocar al objeto original, se mantiene con los mismos datos sin modificación alguna.
2025-03-29 19:08:08
http://php5.kiev.ua/manual/ru/class.datetimeimmutable.html

    Поддержать сайт на родительском проекте КГБ