PHP친콰SQL Server돨좃몸휑퍅뇹잿변鑒
2018-09-07 12:11
//瞳PHP櫓뇹잿휑퍅렷끽꼇렘긱,궐흔헹좃몸휑퍅裂쇌宮뀌돨墩룀?맡等척곗켱?
//匡숭츰:.php3
//瞳賈痰侶좃몸변鑒품,狼邱쉥휑퍅샀휑퍅珂쇌瘻뻣냥timestamp잚謹。
//흔:
//$today=mktime(0,0,0,date(m),date(d),date(Y));
/****친콰sqlserver櫓돨dateadd변鑒*******
$part잚謹:string
혤令렀鍋:year,month,day,hour,min,sec
깊刻:狼藤속돨휑퍅돨컴몸꼬롸
$n잚謹:鑒令
깊刻:狼藤속뜩?名Ц夏?part엄땍藤속컴몸꼬롸
옵槨맏鑒
$datetime잚謹:timestamp
깊刻:藤속돨샘鑒
럿쀼잚謹:timestamp
**************써監**************/
functiondateadd($part,$n,$datetime){
$year=date(Y,$datetime);
$month=date(m,$datetime);
$day=date(d,$datetime);
$hour=date(H,$datetime);
$min=date(i,$datetime);
$sec=date(s,$datetime);
$part=strtolower($part);
$ret=0;
switch($part){
caseyear:
$year+=$n;
break;
casemonth:
$month+=$n;
break;
caseday:
$day+=$n;
break;
casehour:
$hour+=$n;
break;
casemin:
$min+=$n;
break;
casesec:
$sec+=$n;
break;
default:
return$ret;
break;
}
$ret=mktime($hour,$min,$sec,$month,$day,$year);
return$ret;
}
/****친콰sqlserver櫓돨datediff변鑒*******
$part잚謹:string
혤令렀鍋:year,month,day,hour,min,sec
깊刻:狼藤속돨휑퍅돨컴몸꼬롸
$date1,$date2잚謹:timestamp
깊刻:狼궐싹돨좃몸휑퍅
럿쀼잚謹:鑒令
**************써監*(*************/
functiondatediff($part,$date1,$date2){
//$diff=$date2-$date1;
$year1=date(Y,$date1);
$year2=date(Y,$date2);
$month2=date(m,$date2);
$month1=date(m,$date1);
$day2=date(d,$date2);
$day1=date(d,$date1);
$hour2=date(d,$date2);
$hour1=date(d,$date1);
$min2=date(i,$date2);
$min1=date(i,$date1);
$sec2=date(s,$date2);
$sec1=date(s,$date1);
$part=strtolower($part);
$ret=0;
switch($part){
caseyear:
$ret=$year2-$year1;
break;
casemonth:
$ret=($year2-$year1)*12+$month2-$month1;
break;
caseday:
$ret=(mktime(0,0,0,$month2,$day2,$year2)-mktime(0,0,0,$month1,$day1,$year1))/(3600*24);
break;
casehour:
$ret=(mktime($hour2,0,0,$month2,$day2,$year2)-mktime($hour1,0,0,$month1,$day1,$year1))/3600;
break;
casemin:
$ret=(mktime($hour2,$min2,0,$month2,$day2,$year2)-mktime($hour1,$min1,0,$month1,$day1,$year1))/60;
break;
casesec:
$ret=$date2-$date1;
break;
default:
return$ret;
break;
}
return$ret;
}
}
文章标题:PHP친콰SQL Server돨좃몸휑퍅뇹잿변鑒
文章链接:http://soscw.com/index.php/essay/11610.html