Calculating duration between two dates
You can do a little tweak.

After you get the only date in YYYY-MM-DD string format, concate 00:00:00 as time to the string. then you can get unix time format by using function strtotime() that takes a string date format and returns an integer of time format (unix).

Hopefully this helps you getting the correct duration.