//获取当天的星期(1-7)
function GetWeek($times)
{
$res = date('w', strtotime($times));
if($res==0)
$res=7;
return $res;
}
//获取当天时间
function GetTime($times)
{
$res = date('H:i', strtotime($times));
return $res;
}
//获取现在过几月的的时间
function GetMonth($Month,$type='l')
{
if(!strcmp($type,'b'))
$res=date("Y-m-d H:i:s",strtotime("-$Month months"));
if(!strcmp($type,'l'))
$res=date("Y-m-d H:i:s",strtotime("+$Month months"));
return $res;
}
//获取当前时间
function GetCurrentDateTime()
{
$res=date("Y-m-d H:i:s",time());
return $res;
}
//获取当前时间隔几小时之前或之后的时间
function GetDiffHours($hours,$type='l')
{
if(!strcmp($type,'b'))
$res=date("Y-m-d H:i:s",strtotime("-$hours hour"));
if(!strcmp($type,'l'))
$res=date("Y-m-d H:i:s",strtotime("+$hours hour"));
return $res;
}
//间隔几分钟之前或之后的时间
function GetDiffMinute($Minute,$type='l')
{
if(!strcmp($type,'b'))
$res=date("Y-m-d H:i:s",strtotime("-$Minute minute"));
if(!strcmp($type,'l'))
$res=date("Y-m-d H:i:s",strtotime("+$Minute minute"));
return $res;
}
//间隔几秒之前或之后的时间
function GetDiffSec($sec,$type='l')
{
if(!strcmp($type,'b'))
$res=date("Y-m-d H:i:s",strtotime("-$sec second"));
if(!strcmp($type,'l'))
$res=date("Y-m-d H:i:s",strtotime("+$sec second"));
return $res;
}
//间隔几个星期之前或之后的时间
function GetDiffWeek($Week,$type='l')
{
if(!strcmp($type,'b'))
$res=date("Y-m-d H:i:s",strtotime("-$Week week"));
if(!strcmp($type,'l'))
$res=date("Y-m-d H:i:s",strtotime("+$Week week"));
return $res;
}
// 间隔几天之间的时间
function GetDiffDays($days,$type='l')
{
if(!strcmp($type,'b'))
$res=date("Y-m-d H:i:s",strtotime("-$days day"));
if(!strcmp($type,'l'))
$res=date("Y-m-d H:i:s",strtotime("+$days day"));
return $res;
}
//间隔几年之前或之后的时间
function GetDiffYears($year,$type='l')
{
if(!strcmp($type,'b'))
$res=date("Y-m-d H:i:s",strtotime("-$year year"));
if(!strcmp($type,'l'))
$res=date("Y-m-d H:i:s",strtotime("+$year year"));
return $res;
}
|