1--TEST-- 2Test DateTime::modify() function : basic functionality 3--FILE-- 4<?php 5/* Prototype : public DateTime DateTime::modify ( string $modify ) 6 * Description: Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime(). 7 * Source code: ext/date/php_date.c 8 * Alias to functions: public date_modify() 9 */ 10 11 //Set the default time zone 12date_default_timezone_set("Europe/London"); 13 14echo "*** Testing DateTime::modify() : basic functionality ***\n"; 15 16// Create a date object to modify 17$datetime = new DateTime("2009-01-31 14:28:41"); 18 19$datetime->modify("+1 day"); 20echo "After modification 1: " . $datetime->format("D, d M Y") . "\n"; 21 22$datetime->modify("+1 week 2 days 4 hours 2 seconds"); 23echo "After modification 2: " . $datetime->format("D, d M Y H:i:s") . "\n"; 24 25$datetime->modify("next Thursday"); 26echo "After modification 3: " . $datetime->format("D, d M Y") . "\n"; 27 28$datetime->modify("last Sunday"); 29echo "After modification 4: " . $datetime->format("D, d M Y") . "\n"; 30 31?> 32===DONE=== 33--EXPECTF-- 34*** Testing DateTime::modify() : basic functionality *** 35After modification 1: Sun, 01 Feb 2009 36After modification 2: Tue, 10 Feb 2009 18:28:43 37After modification 3: Thu, 12 Feb 2009 38After modification 4: Sun, 08 Feb 2009 39===DONE=== 40