|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68268 DatePeriod: Getter for start date, end date and interval
Submitted: 2014-10-20 08:23 UTC Modified: 2014-12-01 04:52 UTC
From: dev at mabe dot berlin Assigned: stas (profile)
Status: Closed Package: Date/time related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2014-10-20 08:23 UTC] dev at mabe dot berlin
From manual page:

Currently it's not possible to get the start date, the end date and the interval of an existing DatePeriod instance.

Test script:
$start = new DateTime('2000-01-01 00:00:00', new DateTimeZone('Europe/Berlin'));
$end   = new DateTime('2000-01-31 00:00:00', new DateTimeZone('UTC'));
$interval = new DateInterval('P1D');
$period   = new DatePeriod($start, $interval, $end);

var_dump($period->getStartDate()->format('Y-m-d H:i:s'));

var_dump($period->getEndDate()->format('Y-m-d H:i:s'));


Expected result:
string(19) "2000-01-01 00:00:00"
string(13) "Europe/Berlin"
string(19) "2000-01-31 00:00:00"
string(3) "UTC"
string(12) "+0-0-1-0-0-0"

Actual result:
Functions getStartDate, getEndDate and getDateInterval are missing


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-01 04:52 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 [2014-12-01 04:52 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC