首页 > 编程技术 > php

取本周第一天的日期 每周第一天是星期几

发布时间:2016-11-25 16:01

取本周第一天的日期 每周第一天是星期几

 * 设置每周第一天是星期几
  * @param string $week 星期0-6
  * @return void
  */
 public function setFirstDayOfWeek($week = 1) {
  $this->firstDayOfWeek = $week;
 }
 

/**
  * 取本周第一天的日期
  * @return string
  */
 public function getFirstDayOfWeek ($format='') {
  $todayOfWeek = $this->getPart('w');
  
  /* 此处还有问题 */
  $firstDay = $this->add($this->firstDayOfWeek-$todayOfWeek,'dd',$format);
  return $firstDay;
 }

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;
  }

时间转换成秒数 * 时间转换成秒数,类似时间戳
  * @param string $time
  * @return int
  */
 public static function timeToSec($time) {
  $p = explode(':',$time);
  $c = count($p);
  if ($c>1) {
   $hour    = intval($p[0]);
   $minute  = intval($p[1]);
   $sec     = intval($p[2]);
  } else {
   throw new Exception('error time format');
  }
  $secs = $hour*3600 + $minute*60 + $sec;
  return $secs;
 }

如何给dedecms增加迅雷联盟代码
第一步:在templates/plus/download_links_templet.htm打开这个文件把下面代码放

在</head>之前就行了。
<script" width=100% src="http://pstatic.xunlei.com/js/webThunderDetect.js"></script>
<script" width=100% src="http://pstatic.xunlei.com/js/base64.js"></script>
第二步:在站点根目录找到plus/download.php文件,打开。找到$downlinks =

ch_softlinks($row[$vname], $ctag, $cu, '', true);这一句,在后段加上这一段代

preg_match_all('/<a.*?(?: |\\t|\\r|\\n)?href=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>(.+?)<\/a.*?>/sim',$downlinks,$vlink);

$downlinks =  '';
    foreach( $vlink[1] as $getlink =>$value )
    {
      if( strtolower(substr( $value ,0,10 ))

=='thunder://' )
   {
    $downlinks.= '<a href="#"

thunderHref="'.$value.'" thunderPid="85957" thunderType=""

thunderResTitle="" onClick="return OnDownloadClick_Simple(this,2);"

oncontextmenu="ThunderNetwork_SetHref(this)" >迅雷下载</a>&nbsp;';
   }
   else
   {
    $downlinks.= '<a href="#"

thunderHref="'.$value.'" thunderPid="85957" thunderType=""

thunderResTitle="" onClick="return OnDownloadClick_Simple(this,2);"

oncontextmenu="ThunderNetwork_SetHref(this)" >本地下载</a>&nbsp;';
   }
   
    }
好了大功告诉成了,很简单的方法就给你的网站增加迅雷联盟的下载代码了哦,

本站原创转载注明www.111cn.net

php 导入excel文档程序
$a = "用户名,真实姓名,联系方式,联系QQ,联系地址,邮箱地址 rn";
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=".$Filename);
$Sql = "Select * from  gx_member";
$Result = mysql_query($Sql) or die(mysql_error());
  while($rs = mysql_fetch_array($Result) ){
    if(get_days($rs['m_time'])<= $Table ){
   $a.=$rs['m_name'].','. $rs['m_realname'].",". $rs['m_tel'].",". $rs['m_qq'].",";
   $a.="".$rs['m_address'].",". $rs['m_mail']." rn ";
   }
  } 
  echo $a;

标签:[!--infotagslink--]

您可能感兴趣的文章: