//擷取當天的星期(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; } |