Reputation: 549
When I vardump a DateInterval object, in PHP 7.2.1, I get the following output:
object(DateInterval)#4 (16) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(14)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(14)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
There is another thread with the same question but is marked as duplicate. The link given here doesn't describe what I want to know.
NOTE: I am able to access all the properties for these DateInterval Object. I need a little knowledge about the properties not mentioned in the documentation.
Please tell me what are these properties?
Upvotes: 2
Views: 140
Reputation: 1172
I don't have a definitive answer, but since you've been waiting so long, and no one has answered, I'll give you my guess.
I originally thought they were there for optional use, but as far as I can tell, there's no way to set them, or to display them with DateInterval::format(). So my guess is that they're there for future use.
They are kind of baffling because, for example, what would a designation like weekday
mean for an interval of time, which could be many years, a month, or a few microseconds. Even if it's a single day, it's a duration, not a particular day.
[Update] After reading all of the answers in the duplicate link, I found this:
In PHP 5.3, internal functionality was added to allow print_r() to show details of the underlying timestamp value held by an instance of DateTime, to assist with debugging. A side effect of this change is that when the object is dumped to text, these phantom public properties are added to the instance.
This doesn't really answer the question of what they're for, but it explains why they can't be set or displayed.
Upvotes: 0