datetime - How to convert difference between dates into years using php -


I have the expiration dates for dates and formats (mm / yyyy) in my format. I want to show the difference of dates in years, months.

Example:

  Start date 09/2008 end date 07/2010  

should read the display

  1 year, 10 months  

I appreciate any help.

Thank you.

$ start = datetime :: vs format ('m / y', '0 9 / 2008 '); $ End = DateTime :: createFromFormat ('M / Y', '07 / 2010 '); $ Diff = $ start- & gt; Different ($ end); Copy $ diff- & gt; Format ('% Y Year,% m Month');

Note that this requires PHP 5.3.0 or higher.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -