Skip to content
Advertisement

Find difference between two datetimes and format at Y-m-d H:i:s

I’m trying to get the difference between two datetimes and return it as a datetime. I’ve found examples using diff but I can’t seem to get it right.

JavaScript

However $totaltime logs 0000-00-00 00:00:00 to my DB. Is this because I’m not formatting my totaltime variable?

Advertisement

Answer

I’m not sure what format you’re looking for in your difference but here’s how to do it using DateTime

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement