1--TEST-- 2Test date_sub() function : basic functionality 3--CREDITS-- 4Felix De Vliegher <felix.devliegher@gmail.com> 5--FILE-- 6<?php 7date_default_timezone_set('UTC'); 8/* Prototype : void date_sub(DateTime object, DateInterval interval) 9 * Description: Subtracts an interval from the current date in object. 10 * Source code: ext/date/php_date.c 11 * Alias to functions: 12 */ 13 14echo "*** Testing date_sub() : basic functionality ***\n"; 15 16// Initialise all required variables 17$startDate = '2008-01-01 12:25'; 18$format = 'Y-m-d H:i:s'; 19$intervals = array( 20 'P3Y6M4DT12H30M5S', 21 'P0D', 22 'P2DT1M', 23 'P1Y2MT23H43M150S' 24); 25 26$d = new DateTime($startDate); 27var_dump( $d->format($format) ); 28 29foreach($intervals as $interval) { 30 date_sub($d, new DateInterval($interval) ); 31 var_dump( $d->format($format) ); 32} 33 34?> 35===DONE=== 36--EXPECT-- 37*** Testing date_sub() : basic functionality *** 38string(19) "2008-01-01 12:25:00" 39string(19) "2004-06-26 23:54:55" 40string(19) "2004-06-26 23:54:55" 41string(19) "2004-06-24 23:53:55" 42string(19) "2003-04-24 00:08:25" 43===DONE=== 44