DateSeasons.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Biz\Datetime;
  3. /**
  4. * basetime
  5. */
  6. class DateSeasons extends BaseTime {
  7. /**
  8. * 时间信息获取
  9. * @var string
  10. */
  11. public function parseTime($params){
  12. $res = $this->GetTimesSeason($params[0]);
  13. return $res;
  14. }
  15. //获取指定日期起始时间:季
  16. public function GetTimesSeason($type){
  17. $m = date('m',time());
  18. $sm = ceil($m/3);
  19. $sm = ($sm-1)*3+1;
  20. $curm = date("Y-$sm-1",time());
  21. if($type == 'pre'){
  22. $res['start'] = date('Y-m-d 00:00:00',strtotime($curm.'-3month'));
  23. $res['end'] = date('Y-m-d 23:59:59',strtotime($curm.'-1day'));
  24. }else if($type=='cur'){
  25. $res['start'] = date('Y-m-d 00:00:00',strtotime($curm));
  26. $res['end'] = date('Y-m-d 23:59:59',strtotime($curm.'+3month-1day'));
  27. }else{
  28. $res['start'] = date('Y-m-d 00:00:00',strtotime($curm.'+3month'));
  29. $res['end'] = date('Y-m-d 23:59:59',strtotime($curm.'+6month-1day'));
  30. }
  31. return $res;
  32. }
  33. }