關(guān)于“php_datetime版本”的問題,小編就整理了【2】個(gè)相關(guān)介紹“php_datetime版本”的解答:
php里獲取前一天的時(shí)間?//獲得當(dāng)前時(shí)間
//date()格式化時(shí)間返回String類型。 date("Y-m-d H:i:s")
$current_date = date(’Y-m-d’,time());
//根據(jù)當(dāng)前時(shí)間加一周后
$weekLater = date(’Y-m-d’,strtotime("$current_date + 1 week"));
echo $weekLate;
// 2009-05-26 加一天的日期
$tomorrow = date(’Y-m-d’,strtotime("2009-05-26 + 1 day"));
echo $tomorrow; // 2009-05-27
也可以這樣 date("Y-m-d",strtotime("-1 day")) ;直接獲得前一天時(shí)間
如何利用php獲取當(dāng)前具體日期時(shí)間?使用date函數(shù)。date ( string $format [, int $timestamp ] )返回將整數(shù) timestamp 按照給定的格式字串而產(chǎn)生的字符串。如果沒有給出時(shí)間戳則返回本地當(dāng)前時(shí)間。
到此,以上就是小編對(duì)于“php_datetime版本”的問題就介紹到這了,希望介紹關(guān)于“php_datetime版本”的【2】點(diǎn)解答對(duì)大家有用。