php - Datetime Difference Error -


I have a problem when I use the difference of datetime.

Here is the php code $ datetime1 = new date time ('2009-10-11'); $ Datetime2 = new date time ('2009-10-13'); $ Interval = $ datetime1- & gt; Different ($ datetime2); Copy $ interval-> day;

The correct result should be 2. But unfortunately this is the result of 6015 . Even when I change my date, its still 6015 are you facing this problem? I tried to run the script from other computers but its work.

Try it out, $ start_date = new date time (" 2009-10-11 "); $ End_date = new date time ("2009-10-13"); $ Interval = $ start_data- & gt; Different ($ end_date); Echo "result" $ interval-> Y "years,". $ Interval-> Me "Months,". $ Interval-> D. "day";

You can enter $ interval-> Day to $ inter-> d. Change to Day "

You can see your answer on the date difference for more information.

This can help you.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -