多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
#### php字符串类型时间转为秒数 ```php $len = "00:05:10.11"; $time = date_parse($len); $seconds = $time['hour'] * 3600 + $time['minute'] * 60 + $time['second']; ``` #### 判断两天是否是同一天 ```php //判断两天是否是同一天 function isDiffDays($last_date, $this_date) { if (($last_date['year'] === $this_date['year']) && ($this_date['yday'] === $last_date['yday'])) { return true; } else { return false; } ``` #### 传入时间计算距离现在第几周 > 未区分星期一,直接计算 ```php // 传入开学时间计算第几周 public function current_week($time_chuo_of_first_day = '') { //今天的时间戳 $month = date('n'); //获取月 n $day = date('d'); //获取日 d $year = date('Y'); //获取年 Y $time_chuo_of_current_day = mktime(0, 0, 0, $month, $day, $year); $cha = ($time_chuo_of_current_day - $time_chuo_of_first_day) / 60 / 60 / 24; $zhou = (int)(($cha+1) / 7 + 1); return $zhou; } ``` > 传入周,计算周一的日期 ```php // 计算周一的时间 public function mon($date){ $now = strtotime($date); //当时的时间戳 $number = date("w",$now); //当时是周几 $number = $number == 0 ? 7 : $number; //如遇周末,将0换成7 $diff_day = $number - 1; //求到周一差几天 return date("Y-m-d",$now - ($diff_day * 60 * 60 * 24)); } ```