What is the difference between days and "d" in DateInterval

When I use the DateInterval class, it returns the property names β€œd” and then the other property names β€œDays”. I really got confused depending on what the difference between the two is. Can someone explain.

Below is an example of an object that was returned in my code.

DateInterval( y = 0 m = 1 d = 1 h = 3 i = 16 s = 6 weekday = 0 weekday_behavior = 0 first_last_day_of = 0 invert = 1 days = 31 special_type = 0 special_amount = 0 have_weekday_relative = 0 have_special_relative = 0 
+8
source share
1 answer
  • d - days from the beginning of the month, which must be added after adding months - (Feb 23 - Jan 1).d == 22 )
  • days - the total number of days - (Feb 23 - Jan 1).days == 31 + 22 )

From the documentation :

d

Number of days.

days

If the DateInterval object was created by DateTime :: diff (), then this is the total number of days between the start and end dates. Otherwise, the days will be FALSE.

Prior to PHP 5.4.20 / 5.5.4, instead of FALSE, you will get -99999 when accessing the property.

+12
source

Source: https://habr.com/ru/post/987885/


All Articles