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'

WBOY
Release: 2016-07-25 09:06:24
Original
995 people have browsed it
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
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template