Home >Backend Development >PHP Tutorial >date_diff calculates the interval between 'operation time' and 'current time'

date_diff calculates the interval between 'operation time' and 'current time'

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 09:06:241027browse
There are many similar comments on many blogs: xx minutes xx seconds, the time to display comments is long, today I made one using PHP's date_diff.                  
                                                                                                                                                                                                                                                                                                       



                                                                                                                                                                                                                                                                                  can be
                 $interval = date_diff($datetime1, $datetime2) ;
               $psdate=null;
                                                                                                            if ($interval->y>0){ ');
  1.                                                                                                                                                                                                else if($interval->d>0){
  2.                                                                                                                                                                                                              h>0){
  3.                  $psdate= $interval->format('%h hour %i minute %s second'); ->format('%i minutes %s seconds');
  4.                                                                                                                                                                                          }
  5. Copy Code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn