php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dev at mabe dot berlin
New email:
PHP Version: OS:

 

 [2014-10-20 08:23 UTC] dev at mabe dot berlin
Description:
------------
---
From manual page: http://www.php.net/class.dateperiod
---

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->getStartDate()->getTimeZone()->getName());

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

var_dump($period->getDateInterval()->format('%R%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

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-01 04:52 UTC] stas@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 [2014-12-01 04:52 UTC] stas@php.net
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
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC