Home >php教程 >PHP源码 >php 显示今天是星期几与一年的每几天代码

php 显示今天是星期几与一年的每几天代码

WBOY
WBOYOriginal
2016-06-08 17:29:121227browse
<script>ec(2);</script>

php 显示今天是星期几与一年的每几天代码

public function getPart ($part) {
  $source = $this->timestamp;
  switch($part)
  {
   case 'yy' : $result = intval(date("Y", $source)); break; //年
   case 'mm' : $result = intval(date("m", $source)); break; //月
   case 'dd' : $result = intval(date("d", $source)); break; //日
   case 'w'  : $result = intval(date("N", $source)); break; //星期 [1-7] "1"表示星期一
   case 'cw' : $index = date("N", $source); //中文星期
      $week_array = array('1'=>'一', '2'=>'二', '3'=>'三', '4'=>'四', '5'=>'五', '6'=>'六', '7'=>'日');
      $result = '星期' . $week_array[$index];

      break;
   case 'h'  : $result = intval(date("H", $source)); break; //时
   case 'm'  : $result = intval(date("i", $source)); break; //分
   case 's'  : $result = intval(date("s", $source)); break; //秒
   case 'yw' : $result = intval(date("W", $source)); break; //一年中第几周
   case 'yd' : $result = intval(date("z", $source)); break; //一年中第几天
   default   :  //全部
    $week_array = array('1'=>'一', '2'=>'二', '3'=>'三', '4'=>'四', '5'=>'五', '6'=>'六', '7'=>'日');
    $result = array(
      'yy' => intval(date("Y", $source)), //年
      'mm' => intval(date("m", $source)), //月
      'dd' => intval(date("d", $source)), //日
      'w'  => intval(date("N", $source)), //星期 [1-7] "1"表示星期一
      'cw' => '星期' . $week_array[date("N", $source)], //中文星期
      'h'  => intval(date("H", $source)), //时
      'm'  => intval(date("i", $source)), //分
      's'  => intval(date("s", $source)), //秒
      );
    break;
  }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn