<?php
date_default_timezone_set(
'prc'
);
//預設時區
echo
"今天:"
,
date
(
"y-m-d"
,time()),
"
";
echo
"今天:"
,
date
(
"y-m-d"
,
strtotime
(
"18 june 2008"
)),
"
";
echo
"昨天:"
,
date
(
"y-m-d"
,
strtotime
(
"-1 day"
)),
"
";
echo
"明天:"
,
date
(
"y-m-d"
,
strtotime
(
"+1 day"
)),
"
";
echo
"一周後:"
,
date
(
"y-m-d"
,
strtotime
(
"+1 week"
)),
"
";
echo
"一周零兩天四小時兩秒後:"
,
date
(
"y-m-d g:h:s"
,
strtotime
(
"+1 week 2 days 4 hours 2 seconds"
)),
"
";
echo
"下個星期四:"
,
date
(
"y-m-d"
,
strtotime
(
"next thursday"
)),
"
";
echo
"上個周一:"
.
date
(
"y-m-d"
,
strtotime
(
"last monday"
)).
"
";
echo
"乙個月前:"
.
date
(
"y-m-d"
,
strtotime
(
"last month"
)).
"
";
echo
"乙個月後:"
.
date
(
"y-m-d"
,
strtotime
(
"+1 month"
)).
"
";
echo
"十年後:"
.
date
(
"y-m-d"
,
strtotime
(
"+10 year"
)).
"
";
?>
距離某天的時間(php實現)?
$date1
=
strtotime
(
'2011-04-30'
);
//把日期轉換成時間戳
$date2
= time();
//取當前時間的時間戳
$nowtime
=
strftime
(
"%y年-%m月-%d日 "
,
$date2
);
//格式化輸出日期
$days
=
round
((
$date1
-
$date2
)/3600/24);
//四捨五入
echo
"今天是"
.
$nowtime
.
""
;
echo
"
距".
strftime
(
"%y年-%m月-%d日 "
,
$date1
).
"還有"
.
$days
.
"天"
;
PHP 前一天 後一天時間
date default timezone set prc 預設時區 echo 今天 date y m d time echo 今天 date y m d strtotime 18 june 2008 echo 昨天 date y m d strtotime 1 day echo 明天 date y...
時間操作(前一天 後一天 間隔天數)
2 獲取前一天 後一天 獲取後一天時間 如 2015 03 07 today datetime.date.today temp datetime.timedelta days 1 nextday today temp print nextday 獲取前一天時間 如 2015 03 05 today ...
mysql獲取當前時間,前一天,後一天
負責的專案中,使用的是mysql資料庫,頁面上要顯示當天所註冊人數的數量,獲取當前的年月日,我使用的是 curdate 錯誤的sql語句 eg select count from user where registerdate curdate and registerdate curdate 1 雖...