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

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -