中文字幕日韩一区二区_国产一区二区av_国产毛片av_久久久久国产一区_色婷婷电影_国产一区二区精品

PHP輸出時(shí)間差函數(shù)代碼

php輸出時(shí)間差函數(shù)

復(fù)制代碼 代碼如下:
<?php 
date_default_timezone_set('PRC'); //默認(rèn)時(shí)區(qū) 
echo "今天:",date("Y-m-d",time()),"<br>"; 
echo "今天:",date("Y-m-d",strtotime("18 june 2008")),"<br>"; 
echo "昨天:",date("Y-m-d",strtotime("-1 day")), "<br>"; 
echo "明天:",date("Y-m-d",strtotime("+1 day")), "<br>"; 
echo "一周后:",date("Y-m-d",strtotime("+1 week")), "<br>"; 
echo "一周零兩天四小時(shí)兩秒后:",date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds")), "<br>"; 
echo "下個(gè)星期四:",date("Y-m-d",strtotime("next Thursday")), "<br>"; 
echo "上個(gè)周一:".date("Y-m-d",strtotime("last Monday"))."<br>"; 
echo "一個(gè)月前:".date("Y-m-d",strtotime("last month"))."<br>"; 
echo "一個(gè)月后:".date("Y-m-d",strtotime("+1 month"))."<br>"; 
echo "十年后:".date("Y-m-d",strtotime("+10 year"))."<br>"; 
?>

在學(xué)習(xí)php 的時(shí)候,經(jīng)常會(huì)用到獲取現(xiàn)在之前或之后,某個(gè)時(shí)間段的日期。現(xiàn)在已經(jīng)進(jìn)行收集,大家同時(shí)也可以進(jìn)行擴(kuò)展豐富
復(fù)制代碼 代碼如下:
//獲取當(dāng)天的星期(1-7)
function GetWeek($times)
{
    $res = date('w', strtotime($times));
    if($res==0)
       $res=7;
    return $res;
}
//獲取當(dāng)天時(shí)間
function GetTime($times)
{
    $res = date('H:i', strtotime($times));
    return $res;
}
//獲取現(xiàn)在過幾月的的時(shí)間
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;
}
//獲取當(dāng)前時(shí)間
function GetCurrentDateTime()
{
    $res=date("Y-m-d H:i:s",time());
    return $res;
}
//獲取當(dāng)前時(shí)間隔幾小時(shí)之前或之后的時(shí)間
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;    
}
//間隔幾分鐘之前或之后的時(shí)間
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;    
}
//間隔幾秒之前或之后的時(shí)間
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;    
}

//間隔幾個(gè)星期之前或之后的時(shí)間
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;    
}
// 間隔幾天之間的時(shí)間
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;    
}
//間隔幾年之前或之后的時(shí)間
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;    
}

php技術(shù)PHP輸出時(shí)間差函數(shù)代碼,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产精品www| 国产一级片免费在线观看 | 亚洲网站在线播放 | 欧美8一10sex性hd | 久久久婷婷 | 欧美精品一区二区三区在线播放 | 天堂久久一区 | 亚洲国产精品久久久久久 | 精品www | 国产成人99久久亚洲综合精品 | 欧美天堂| 一区二区免费在线观看 | 国产在线一级片 | 亚洲国产一| 亚洲人人舔人人 | 国外成人在线视频网站 | 91电影| 久久精品国产清自在天天线 | 国产成人在线视频 | 亚洲免费在线 | 日韩中文字幕 | 电影在线 | 国产精品色一区二区三区 | 国产一区二区电影网 | 中文字幕视频在线 | 日韩黄色小视频 | 玖玖综合网 | 红色av社区 | se婷婷| 午夜影视网 | 亚洲精品一 | 二区av| 日本一道本视频 | 黑人巨大精品欧美黑白配亚洲 | 毛片国产| 韩国av一区二区 | 91av视频在线| 韩日在线观看视频 | 久久99精品久久久久蜜桃tv | 久久久久久久国产 | 久久免费高清视频 |