标签:time UNC pre min 毫秒级 ndt 时间戳 timediff ==
function timediff ($begin_time,$end_time) { var $starttime = ‘‘ var $endtime = ‘‘ if ($begin_time < $end_time) { $starttime = $begin_time; $endtime = $end_time; } else { $starttime = $end_time; $endtime = $begin_time; } //计算天数 var $timediff = $endtime - $starttime; var $days = parseInt($timediff / 86400); //计算小时数 var $remain = $timediff % 86400; var $hours = parseInt($remain / 3600); //计算分钟数 var $remain = $remain % 3600; var $mins = parseInt($remain / 60); //计算秒数 var $secs = $remain % 60; // $days=>天 // $hours=>时 // $mins=>分 // $secs=>秒 var $res = [$days,$hours,$mins,$secs] return $res }
timediff(开始时间戳,结束时间戳)
都是秒级时间戳 如果只有毫秒级时间戳 上方计算公式都乘1000即可 如:秒级时间戳86400 == 毫秒级时间戳86400000
标签:time UNC pre min 毫秒级 ndt 时间戳 timediff ==
原文地址:https://www.cnblogs.com/yolo-sf/p/13405395.html