Css.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Sports\Controller;
  3. use BaseController\Controller;
  4. use Biz\Match\GetmatchData;
  5. class Css extends Controller {
  6. public function index(){
  7. $data['s_time'] =$this->ts_time();
  8. $s = $_REQUEST['data'];
  9. $arr = [];
  10. if(strstr($s,',')){
  11. $arr1 = explode(",", $s);
  12. if(!empty($arr1)){
  13. foreach($arr1 as $k=>$v){
  14. $arr[]= (int)$v*100;
  15. }
  16. }
  17. }else{
  18. for($i=0;$i<=$s;$i++){
  19. $arr[] = $i+1;
  20. }
  21. }
  22. $data['num'] = count($arr);
  23. $data['e_time'] =$this->ts_time();
  24. Render($data, '1', lang('Tips','Sports')->get('success'));
  25. }
  26. //获取毫秒级时间
  27. public function getMsecToMescdate($msectime)
  28. {
  29. $msectime = $msectime * 0.001;
  30. if(strstr($msectime,'.')){
  31. sprintf("%01.3f",$msectime);
  32. list($usec, $sec) = explode(".",$msectime);
  33. $sec = str_pad($sec,3,"0",STR_PAD_RIGHT);
  34. }else{
  35. $usec = $msectime;
  36. $sec = "000";
  37. }
  38. $date = date("Y-m-d H:i:s.x",$usec);
  39. $mescdate = str_replace('x', $sec, $date);
  40. return $mescdate;
  41. }
  42. /**
  43. * 年月日、时分秒 + 3位毫秒数
  44. * @param string $format
  45. * @param null $utimestamp
  46. * @return false|string
  47. */
  48. public function ts_time($format = 'Y-m-d H:i:s.u', $utimestamp = null) {
  49. if (is_null($utimestamp)){
  50. $utimestamp = microtime(true);
  51. }
  52. $timestamp = floor($utimestamp);
  53. $milliseconds = round(($utimestamp - $timestamp) * 1000);
  54. return date(preg_replace('`(?<!\\\\)u`', $milliseconds, $format), $timestamp);
  55. }
  56. }