php - How to find difference between two time? -


this question has answer here:

i have 2 variable value date type assigned it. want find difference of 2 variable values.

$d1='2016-08-24 12:22:13'; $d2='2016-08-24 12:22:30'; 

difference of d2-d1 17 seconds. how find in php?

// instantiate datetime  $datetimefirst = new datetime('2016-08-24 12:20:00'); $datetimesecond = new datetime('2016-08-24 12:34:00'); //calculate difference $difference = $datetimefirst->diff($datetimesecond); //format output  echo $difference->format('%y-%m-%d %h:%i:%s'); 

reference


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -