123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- /**
- * Created by PhpStorm.
- * User: PFG2018
- * Date: 2019/7/10
- * Time: 10:09
- */
- namespace common\Helps;
- use yii\helpers\StringHelper;
- class Time
- {
- public static function effectiveTime()
- {
- // return date('Y/m').'/01-'.date('Y/m', strtotime('+ 1 month')).'/01'; //有效日期
- return date('Y/m') . '/01-' . date('Y/m/d', strtotime('+ 1 month -1 day')); //有效日期
- }
- public static function TermOfValidity_v3()
- {
- return date('Y.m.d', strtotime('+ 1 month -1 day')); //有效日期
- }
- public static function TermOfValidity()
- {
- return date('Y-m-d', strtotime('+ 1 month -1 day')); //有效日期
- }
- public static function TermOfValidity_v2()
- {
- return date('Y年m', strtotime('+ 1 month')) . '月01日'; //有效日期
- }
- public static function getMonth($time = '', $format = 'Y-m-d')
- {
- $time = $time != '' ? $time : time();
- //获取当前周几
- $week = date('d', $time);
- $date = [];
- $dateArr = [];
- for ($i = 1; $i <= date('t', $time); $i++) {
- $getTime = date($format, strtotime('+' . $i - $week . ' days', $time));
- $date[$i] = $getTime;
- $dateArr[$i]['start'] = strtotime($getTime . ' 00:00:00');
- $dateArr[$i]['end'] = strtotime($getTime . ' 23:59:59');
- }
- p($dateArr);
- // return $date;
- }
- public static function getthemonth($date)
- {
- $firstday = date('Y-m-01', strtotime($date));
- $lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day"));
- return array($firstday, $lastday);
- }
- /**
- * 处理直播状态
- * @param $url 回放地址 如果不为空,就是回放
- * @param $time 直播开始的时间
- * @return string
- */
- public static function getLiveState($url, $time)
- {
- // if (!empty($url)) {
- // return '回放';
- //
- // } else {
- //
- // if (strtotime($time) > time()) {
- // return '预告';
- // }
- //
- // if (strtotime($time) < time()) {
- // return '直播中';
- // }
- // }
- return '回放';
- }
- }
|