csjoz11

导航

月周日时间

<div class="rep-but cyx-team-date ui-mar-t10">
<button type="button" class="btn-all <?php if($_GET['place']==0 || !$_GET['place']){?>active<?php }?>" id="today" sdate="<?php echo date('Y-m-d', time()) ?>" edate="<?php echo date('Y-m-d', time()) ?>">今日</button>
<button type="button" class="btn-all <?php if($_GET['place']==1){?>active<?php }?>" id="yesterday" sdate="<?php echo date('Y-m-d', strtotime('yesterday')) ?>" edate="<?php echo date('Y-m-d', strtotime('yesterday')) ?>">昨日</button>
<button type="button" class="btn-all <?php if($_GET['place']==2){?>active<?php }?>" id="this-week" sdate="<?php echo date('Y-m-d', strtotime('+1 day -'.(date('N')).' day')) ?>" edate="<?php echo date('Y-m-d', strtotime('today')) ?>">本周</button>
<button type="button" class="btn-all <?php if($_GET['place']==3){?>active<?php }?>" id="last-week" sdate="<?php echo date('Y-m-d', strtotime('+1 day -1 week -'.(date('N')).' day')) ?>" edate="<?php echo date('Y-m-d', strtotime('-1 week +'.(7-date('N')).' day')) ?>">上周</button>
<button type="button" class="btn-all <?php if($_GET['place']==4){?>active<?php }?>" id="this-month" sdate="<?php echo date('Y-m-'.'01', strtotime('-'.(date('N')-1).' day')) ?>" edate="<?php echo date('Y-m-d', strtotime('today')) ?>">本月</button>
<button type="button" class="btn-all <?php if($_GET['place']==5){?>active<?php }?>" id="last-month" sdate="<?php echo date('Y-m-d', strtotime('-1 month -'.(date('j')-1).' day')) ?>" edate="<?php echo date('Y-m-d', strtotime('-1 day', strtotime(date('Y-m-'.'01')))) ?>">上月</button>
</div>
<input type="hidden" name="place" id="place" value="0"/>
<script type="text/javascript">
$(".rep-but button").each(function() {
$(this).click(function() {
var sdate = $(this).attr("sdate");
var edate = $(this).attr("edate");

var n = $('.rep-but button').index($(this));
$("#place").val(n);
$("input[name='start_time']").val(sdate);
$("input[name='end_time']").val(edate);
$(".rep-but button").removeClass("active");
$(this).addClass("active");
});
});
</script>


 
————————————————————————
switch($search_type)
{
case '1': //指定日期
if($s_date && $e_date) { // 根据填写日期查询
$param['s_date'] = strtotime($s_date);
$param['e_date'] = strtotime($e_date)+86399;
if(empty($s_date) || empty($e_date)) {
ereturn('开始日期和结束日期不能为空');
exit;
}
} else {
/* 查询条件,只查询当天的数据 */
$s_date = date('Y-m-d', strtotime(date('Y-m-d', time())));
$e_date = date('Y-m-d H:i:s', time());
$param['s_date'] = strtotime($s_date);
$param['e_date'] = time();
}
break;
case '2': //昨天
$s_date = date("Y-m-d H:i:s",strtotime(date('Y-m-d',time())."-1 day"));
$e_date = date("Y-m-d H:i:s",strtotime(date('Y-m-d',time())."-1 seconds"));
$param['s_date'] = strtotime($s_date);
$param['e_date'] = strtotime($e_date);
break;
case '3': //今天
$s_date = date('Y-m-d H:i:s', strtotime(date('Y-m-d', time())));
$e_date = date('Y-m-d H:i:s', time());
$param['s_date'] = strtotime($s_date);
$param['e_date'] = strtotime($e_date);
break;
case '4': //上周
$s_date = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1-7,date("Y")));
$e_date = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7-7,date("Y")));
$param['s_date'] = strtotime($s_date);
$param['e_date'] = strtotime($e_date);
break;
case '5': //本周
$s_date = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y")));
$e_date = date('Y-m-d H:i:s', time());
$param['s_date'] = strtotime($s_date);
$param['e_date'] = strtotime($e_date);
break;
case '6': //上月
$s_date = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m")-1,1,date("Y")));
$e_date = date("Y-m-d H:i:s",mktime(23,59,59,date("m") ,0,date("Y")));
$param['s_date'] = strtotime($s_date);
$param['e_date'] = strtotime($e_date);
break;
case '7': //本月
$s_date = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),1,date("Y")));
$e_date = date('Y-m-d H:i:s', time());
$param['s_date'] = strtotime($s_date);
$param['e_date'] = strtotime($e_date);
break;
}

——————————
 //php获取今日开始时间戳和结束时间戳
$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;

//php获取昨日起始时间戳和结束时间戳
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;

//php获取上周起始时间戳和结束时间戳
$beginLastweek=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
$endLastweek=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));

//php获取本月起始时间戳和结束时间戳
$beginThismonth=mktime(0,0,0,date('m'),1,date('Y'));
$endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y')); 
__________________________
$list = array(array());
//昨日时间
$yesterday = intval(strtotime(date("Y-m-d")))-86400;
//本周时间
$week = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
$today_end = strtotime(date("Y-m-d"));
//上周时间
$last_week_day_begin = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1-7,date("Y"));
$last_week_day_end = mktime(0, 0 , 0,date("m"),date("d")-date("w"),date("Y"));
//本月时间
$month_day = strtotime(date("Y-m")."-1");
//上月时间
$month_day_begin = strtotime(date("Y-").(date('m')-1)."-1");
$month_day_end = strtotime(date("Y-m")."-1")-86400;

posted on 2017-07-27 11:44  csjoz11  阅读(145)  评论(0编辑  收藏  举报