Time.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: PFG2018
  5. * Date: 2019/7/10
  6. * Time: 10:09
  7. */
  8. namespace common\Helps;
  9. use yii\helpers\StringHelper;
  10. class Time
  11. {
  12. public static function effectiveTime()
  13. {
  14. // return date('Y/m').'/01-'.date('Y/m', strtotime('+ 1 month')).'/01'; //有效日期
  15. return date('Y/m') . '/01-' . date('Y/m/d', strtotime('+ 1 month -1 day')); //有效日期
  16. }
  17. public static function TermOfValidity_v3()
  18. {
  19. return date('Y.m.d', strtotime('+ 1 month -1 day')); //有效日期
  20. }
  21. public static function TermOfValidity()
  22. {
  23. return date('Y-m-d', strtotime('+ 1 month -1 day')); //有效日期
  24. }
  25. public static function TermOfValidity_v2()
  26. {
  27. return date('Y年m', strtotime('+ 1 month')) . '月01日'; //有效日期
  28. }
  29. public static function getMonth($time = '', $format = 'Y-m-d')
  30. {
  31. $time = $time != '' ? $time : time();
  32. //获取当前周几
  33. $week = date('d', $time);
  34. $date = [];
  35. $dateArr = [];
  36. for ($i = 1; $i <= date('t', $time); $i++) {
  37. $getTime = date($format, strtotime('+' . $i - $week . ' days', $time));
  38. $date[$i] = $getTime;
  39. $dateArr[$i]['start'] = strtotime($getTime . ' 00:00:00');
  40. $dateArr[$i]['end'] = strtotime($getTime . ' 23:59:59');
  41. }
  42. p($dateArr);
  43. // return $date;
  44. }
  45. public static function getthemonth($date)
  46. {
  47. $firstday = date('Y-m-01', strtotime($date));
  48. $lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day"));
  49. return array($firstday, $lastday);
  50. }
  51. /**
  52. * 处理直播状态
  53. * @param $url 回放地址 如果不为空,就是回放
  54. * @param $time 直播开始的时间
  55. * @return string
  56. */
  57. public static function getLiveState($url, $time)
  58. {
  59. // if (!empty($url)) {
  60. // return '回放';
  61. //
  62. // } else {
  63. //
  64. // if (strtotime($time) > time()) {
  65. // return '预告';
  66. // }
  67. //
  68. // if (strtotime($time) < time()) {
  69. // return '直播中';
  70. // }
  71. // }
  72. return '回放';
  73. }
  74. }