Documentation 
Time and frequency from dates
[TFactors, F] = date2time(Settle, Maturity, Compounding, Basis,
EndMonthRule)
Settle  Settlement date. A vector of serial date numbers or date strings. 
Maturity  A vector of serial maturity dates. 
Compounding  Scalar value representing the rate at which the input zero rates were compounded when annualized. This argument determines the formula for the discount factors:

Basis  (Optional) Daycount basis of the instrument. A vector of integers.
For more information, see basis. 
EndMonthRule  (Optional) Endofmonth rule. A vector. This rule applies only when Maturity is an endofmonth date for a month having 30 or fewer days. 0 = ignore rule, meaning that a bond's coupon payment date is always the same numerical day of the month. 1 = set rule on (default), meaning that a bond's coupon payment date is always the last actual day of the month. 
[TFactors, F] = date2time(Settle, Maturity, Compounding, Basis, EndMonthRule) computes time factors appropriate to compounded rate quotes between the settlement and maturity dates.
TFactors is a vector of time factors.
F is a scalar of related compounding frequencies.
date2time is the inverse of time2date.
The difference between yearfrac and date2time is that date2time counts full periods as a whole integer, even if the number of actual days in the periods are different. yearfrac does not count full periods. For example,
yearfrac('1/1/2000', '1/1/2001', 9)
ans = 1.0167
yearfrac for Basis 9 (ACT/360 ISMA) will calculate 366/360 = 1.0167. So, even if the dates have the same month and date, with a difference of 1 in the year, the returned value may not be exactly 1. On the other hand, date2time will calculate one full year period:
date2time('1/1/2000', '1/1/2001', 1, 9)
ans = 1