DateTime::sub
DateTimeImmutable::add
Date/Time
PHP Manual

# The DateTimeImmutable class

(PHP 5 >= 5.5.0, PHP 7)

## 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 DateTimeImmutable createFromMutable ( DateTime `$datetime` )
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

- DateTimeImmutable::add — Adds an amount of days, months, years, hours, minutes and seconds
- DateTimeImmutable::__construct — Returns new DateTimeImmutable object
- DateTimeImmutable::createFromFormat — Returns new DateTimeImmutable object formatted according to the specified format
- DateTimeImmutable::createFromMutable — Returns new DateTimeImmutable object 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 an Unix timestamp
- DateTimeImmutable::setTimezone — Sets the time zone
- DateTimeImmutable::sub — Subtracts an amount of days, months, years, hours, minutes and seconds

DateTime::sub
DateTimeImmutable::add
Date/Time
PHP Manual