Change language

PHP DateTimeImmutable modify () function

Syntax:
DateTimeImmutable DateTimeImmutable::modify (string $modify)
Parameters:This function takes two parameters as above and described below:
  • object:This parameter contains the DateTime object returned by the date_create function().
  • $modifyThis parameter contains a date / time string that is set to modify the specified DataTimeImmutable.
Returns values:This function returns the modified DateTimeImmutable object on success or False on error.The following programs illustrate the DateTimeImmutable::modify() function in PHP:Program 1:This program changes the given date in 5-day increments.
/ / PHP illustration program DateTimeImmutable::modify()
// function 
// create a DateTime object $datetimeImmutable = new DateTimeImmutable ( ’2019-10- 02T00: 00: 00’ );  
// Call date DateTimeImmutable::modify()
// with a step of 5 days as parameters $newDateTimeImmutable = $datetimeImmutable -> modify ( ’+ 5 days’ );  
// Get the modified date in ymd format echo $newDateTimeImmutable -> format ( ’Ymd’ ); ?> Exit:
2019-10 -07
Program 2:This program changes this date in 2 month increments.
// PHP illustration program DateTimeImmutable::modify()
// function 
// Create a DateTime object $datetimeImmutable = new DateTimeImmutable ( ’2019-10-02T00: 00: 00’ );  
// Call date DateTimeImmutable::modify()
// with 2 month increments as parameters $newDateTimeImmutable = $datetimeImmutable -> modify ( ’+ 2 months’ );  
// Get the modified date in ymd format echo $newDateTimeImmutable -> format ( ’Ymd’ ); ?> Exit:
2019-12 -02
Link: https://www.php. net / manual / en / datetimeimmutable.modify.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method