in reply to Problem with DateTime subtract_datetime

Seems to work okay for me. Give an example that "doesn't" work. Possibly use the 'in_units()' method to return something less confusing?
  • Comment on Re: Problem with DateTime subtract_datetime

Replies are listed 'Best First'.
Re^2: Problem with DateTime subtract_datetime
by phildeman (Scribe) on Feb 19, 2015 at 16:59 UTC

    So, if $endDate = "2015-02-24", the result I am getting is 5 months, 2 weeks, 0 days. Whereas, the result should be 0 months, 0 weeks, 5 days.

    However, if $endDate = "2015-06-16' the result is: 3 months, 3 weeks, 3 days. That is correct.

      I get the correct answer, although it's '4 days 11 hours'. Perhaps you should be using 'today()' instead of 'now()' ? Also, try to write an example that doesn't use today() or now(), and uses fixed dates, so that the example will behave the same tomorrow.
      Please note, my response is based on today's date (2015-02-19).