php的日期处理经验集
时间:2007-02-17 来源:PHP爱好者
//由年、月、日合成日期
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
function dateserial($nyear,$nmonth,$nday)
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
{
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
return date("Y/n/j",mktime(0,0,0,$nmonth,$nday,$nyear));
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
}
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$now_rq=date("Y/n/j");//去现在的日期
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$year=date('Y');//取得年
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$month=date('m');//取月
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$month=date('j');//取日
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
//由月份取得所在季度的第一天和最后一天
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
switch($month){
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 1:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 2:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 3:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_begin=dateserial($year-1,10,1);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_end=dateserial($year-1,12,31);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
break;
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 4:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 5:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 6:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_begin=dateserial($year,1,1);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_end=dateserial($year,3,31);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
break;
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 7:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 8:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 9:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_begin=dateserial($year,4,1);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_end=dateserial($year,6,30);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
break;
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 10:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 11:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 12:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_begin=dateserial($year,7,1);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_end=dateserial($year,9,30);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
break;
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
}
php爱好 者站 http://www.phpfans.net php基础|php进阶|php模板.
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
function dateserial($nyear,$nmonth,$nday)
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
{
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
return date("Y/n/j",mktime(0,0,0,$nmonth,$nday,$nyear));
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
}
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$now_rq=date("Y/n/j");//去现在的日期
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$year=date('Y');//取得年
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$month=date('m');//取月
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$month=date('j');//取日
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
//由月份取得所在季度的第一天和最后一天
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
switch($month){
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 1:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 2:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 3:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_begin=dateserial($year-1,10,1);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_end=dateserial($year-1,12,31);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
break;
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 4:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 5:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 6:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_begin=dateserial($year,1,1);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_end=dateserial($year,3,31);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
break;
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 7:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 8:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 9:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_begin=dateserial($year,4,1);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_end=dateserial($year,6,30);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
break;
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 10:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 11:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
case 12:
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_begin=dateserial($year,7,1);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
$quarter_end=dateserial($year,9,30);
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
break;
www.chinaitpower.comArypaWVua7CZYXCxSwwOWklG1
}
php爱好 者站 http://www.phpfans.net php基础|php进阶|php模板.
相关阅读 更多 +