datetime.modify(3) php man page | unix.com

Man Page: datetime.modify

Operating Environment: php

Section: 3

DATETIME.MODIFY(3)							 1							DATETIME.MODIFY(3)

DateTime::modify - Alters the timestamp

       Object oriented style

SYNOPSIS
public DateTime DateTime::modify (string $modify)
DESCRIPTION
Procedural style DateTime date_modify (DateTime $object, string $modify) Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime(3).
PARAMETERS
o $object -Procedural style only: A DateTime object returned by date_create(3). The function modifies this object. o $modify -A date/time string. Valid formats are explained in Date and Time Formats.
RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.6 | | | | | | | Absolute date/time statements now take effect. | | | Previously, only relative parts were used. | | | | | 5.3.0 | | | | | | | Changed the return value on success from NULL to | | | DateTime. | | | | +--------+---------------------------------------------------+
EXAMPLES
Example #1 DateTime.modify(3) example Object oriented style <?php $date = new DateTime('2006-12-12'); $date->modify('+1 day'); echo $date->format('Y-m-d'); ?> Procedural style <?php $date = date_create('2006-12-12'); date_modify($date, '+1 day'); echo date_format($date, 'Y-m-d'); ?> The above examples will output: 2006-12-13 Example #2 Beware when adding or subtracting months <?php $date = new DateTime('2000-12-31'); $date->modify('+1 month'); echo $date->format('Y-m-d') . " "; $date->modify('+1 month'); echo $date->format('Y-m-d') . " "; ?> The above example will output: 2001-01-31 2001-03-03
SEE ALSO
strtotime(3), DateTime.add(3), DateTime.sub(3), DateTime.setDate(3), DateTime.setISODate(3), DateTime.setTime(3), DateTime.setTimes- tamp(3). PHP Documentation Group DATETIME.MODIFY(3)
Related Man Pages
datetime.createfromformat(3) - php
datetimeimmutable.diff(3) - php
datetime(3) - php
datetime.setdate(3) - php
datetime.setisodate(3) - php
Similar Topics in the Unix Linux Community
comparing 2 string variables in unix
Grep a string
Extracting variables from echo
Shell script (KSH) to list ONLY the ID of male employees whose last loging time was during the last
Find all files other than first two files dates &amp; last file date for month