Annotation of embedaddon/php/ext/date/tests/date_add_basic.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test date_add() function : basic functionality
! 3: --CREDITS--
! 4: Felix De Vliegher <felix.devliegher@gmail.com>
! 5: --SKIPIF--
! 6: <?php if (!function_exists('date_add')) echo "skip: date_add() function not found!"; ?>
! 7: --FILE--
! 8: <?php
! 9: date_default_timezone_set('UTC');
! 10: /* Prototype : void date_add(DateTime object, DateInterval interval)
! 11: * Description: Adds an interval to the current date in object.
! 12: * Source code: ext/date/php_date.c
! 13: * Alias to functions:
! 14: */
! 15:
! 16: echo "*** Testing date_add() : basic functionality ***\n";
! 17:
! 18: // Initialise all required variables
! 19: $startDate = '2008-01-01 12:25';
! 20: $format = 'Y-m-d H:i:s';
! 21: $intervals = array(
! 22: 'P3Y6M4DT12H30M5S',
! 23: 'P0D',
! 24: 'P2DT1M',
! 25: 'P1Y2MT23H43M150S'
! 26: );
! 27:
! 28: $d = new DateTime($startDate);
! 29: var_dump( $d->format($format) );
! 30:
! 31: foreach($intervals as $interval) {
! 32: date_add($d, new DateInterval($interval) );
! 33: var_dump( $d->format($format) );
! 34: }
! 35:
! 36: ?>
! 37: ===DONE===
! 38: --EXPECTF--
! 39: *** Testing date_add() : basic functionality ***
! 40: string(19) "2008-01-01 12:25:00"
! 41: string(19) "2011-07-06 00:55:05"
! 42: string(19) "2011-07-06 00:55:05"
! 43: string(19) "2011-07-08 00:56:05"
! 44: string(19) "2012-09-09 00:41:35"
! 45: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>