⑴ 1. 用php列印出前一天的時間格式是2006

echo date('Y',strtotime('-1 day',time()));

補充:date('Y-m-d H:i:s',strtotime('-1 day',time())); //完整的時間格式
echo date('Y-m',strtotime('-1 month',time())); //列印出前一個月

⑵ php中如何獲得當前時間

一、使用函式 date() 實現

在編輯器中輸入<?php echo $showtime=date("Y-m-d H:i:s");?>,點擊回車就可以得知當前的時間。其中Y是代表4位的年份,H是24小時制,i 是分鍾,如: "00" 至 "59" 。s -是秒,如: "00" 至 "59" 。

d 是幾日,二位數字,若不足二位則前面補零。 如: "01" 至 "31" 。m代表月份,二位數字,若不足二位則在前面補零,如: "01" 至 "12" 。

二、使用time函數

在編輯器中輸入echo date("y-m-d",$time)點擊回車就可以得知當前的時間,其中Y是代表4位的年份,m代表月份,二位數字,若不足二位則在前面補零,如: "01" 至 "12" 。d 是幾日,二位數字,若不足二位則前面補零。 如: "01" 至 "31" 。

三、使用strftime函數

在編輯器中輸入echo strftime ("%hh%m %a %d %b" ,time());點擊回車就可以得知當前的時間。

(2)php獲取前一天日期擴展閱讀:

Date/Time 函數

一、time — 返回當前的 Unix 時間戳

二、timezone_abbreviations_list — 別名 DateTimeZone::listAbbreviations

三、timezone_identifiers_list — 別名 DateTimeZone::listIdentifiers

四、timezone_location_get — 別名 DateTimeZone::getLocation

五、date — 格式化一個本地時間/日期

六、getdate — 取得日期/時間信息

七、gettimeofday — 取得當前時間

八、gmdate — 格式化一個 GMT/UTC 日期/時間

九、gmmktime — 取得 GMT 日期的 UNIX 時間戳

⑶ 用PHP怎麼取得7天前的日期

$date = date('Y-m-d', strtotime('-7 days')); //保留年-月-日

<?php echo echo date(」Y-m-d H:i:s」,strtotime(」-7 day」)) ;?> //保留年-月-日 時:分:秒

strtotime('-7 days') 獲得的是時間戳

strtotime('now')); //獲取當前的時間戳

time() //獲取的時間戳

(3)php獲取前一天日期擴展閱讀:

一、使用函式 date() 實現

在編輯器中輸入<?php echo $showtime=date("Y-m-d H:i:s");?>,點擊回車就可以得知當前的時間。其中Y是代表4位的年份,H是24小時制,i 是分鍾,如: "00" 至 "59" 。s -是秒,如: "00" 至 "59" 。

d 是幾日,二位數字,若不足二位則前面補零。 如: "01" 至 "31" 。m代表月份,二位數字,若不足二位則在前面補零,如: "01" 至 "12" 。

二、使用time函數

在編輯器中輸入echo date("y-m-d",$time)點擊回車就可以得知當前的時間,其中Y是代表4位的年份,m代表月份,二位數字,若不足二位則在前面補零,如: "01" 至 "12" 。d 是幾日,二位數字,若不足二位則前面補零。 如: "01" 至 "31" 。

三、使用strftime函數

在編輯器中輸入echo strftime ("%hh%m %a %d %b" ,time());點擊回車就可以得知當前的時間。

⑷ 如何計算給定日期前一天的日期

找一個日期作為基準參考點,通過公式計算給定的日期距離這個日期的天數,然後天數減1,最後通過天數求日期。

給出以下代碼:C/C++(以1900年1月1日為起點):

1. 求天數

intGetBaseDays(intuYear,unsignedintuMonth,unsignedintuDay)
{
if(LTDateCheck(uYear,uMonth,uDay)==false)
{
return-1;
}
//用來計算距離1900年1月1日的天數,傳入年、月、日
intsum=0;
if(uYear>=1900)
{
intX=int(uYear/100);//世紀數
intY=X-int(X/4);
if(uMonth<=2&&uMonth>0)
{
uYear--;
uMonth+=12;
}
sum=int(365.25*(uYear-1900))+int(30.6*(uMonth+1))+uDay-Y-49;
}
//m_iDayOfWeek=(sum+1)%7;//星期
returnsum;//返回距離1900年1月1日的總天數(積日)
}

2. 求日期

booletDateFromDays(unsignedintnDays,unsignedint*iYear,unsignedint*iMonth,unsignedint*iDay)
{
if(nDays<-51)
{
returnfalse;
}
if(nDays<0)
{
intx=int((nDays)/7);
//m_iDayOfWeek=int(nDays-(x-1)*7+1)%7;//1900年1月1日周一
}else
{
//m_iDayOfWeek=int(nDays+1)%7;//1900年1月1日周一
}
intA=nDays,D;
D=int((A+547804.75)/36524.25);
A+=1+D-int(D/4);
A+=51;
*iYear=int(double(A-122.1)/365.25);
D=A-int(365.25**iYear);
*iMonth=int(D/30.6);
*iDay=int(D-int(*iMonth*30.6));
*iYear+=1900;
*iMonth--;
if(*iMonth>12)
{
*iMonth-=12;
}
if(*iMonth<=2)
{
*iYear++;
}
returntrue;
}

⑸ php得到當前時間的前多少天時間

使用PHP的strtotime函數可以獲取指定時間或日期的時間戳,然後再使用date函數格式化時間戳就可以了。

舉例如下:

date_default_timezone_set('PRC');//設置時區

//列印出3天前的時間
echo(date('Y-m-dH:i:s',strtotime("-3day")));

//列印出2個星期前的時間
echo(date('Y-m-dH:i:s',strtotime("-2week")));

//列印出5個小時後的時間
echo(date('Y-m-dH:i:s',strtotime("+5hours")));

//列印出1個星期後的時間
echo(date('Y-m-dH:i:s',strtotime("+1week")));

輸出結果:

⑹ PHP 分別獲取當天以及前一天的 24個小時中每個小時開始及結束 的時間戳

$beginTime=mktime(0,0,0,date("m"),date("d")-1,date("y"));
for($i=0;$i<24;$i++){
$b=$beginTime+($i*3600);
$e=$beginTime+(($i+1)*3600)-1;
echodate("Y-m-dH:i:s",$b)."->".date("Y-m-dH:i:s",$e)." ";
}

有沒有其他辦法我不知道,這個是我所知道的

⑺ PHP獲取當前日期和星期

date("Y年m月d日",time());//時間
date("N",time());//星期

⑻ 用php怎麼獲取當前的前一天和後一天的日期啊

//取當前時間,前一天的時間

$time = date("Y-m-d H:i:s",strtotime("-1 day"));

//取當前時間,後一天的時間

$time = date("Y-m-d H:i:s",strtotime("+1 day"));

⑼ php獲取當前時間的前一天

圖片中的頁面是遠程的還是你的網站上的

⑽ php如何獲得昨天的日期

$time=time()-(1*24*60*60);
echodate("Y-m-d",$time);

( 1 * 24 * 60 * 60 )為1天的時間,當前時間減去一天的時間,即為昨天的時間。