PHP 獲取當天 凌晨 時間戳經常使用代碼

echo strtotime(date('Y-m-d'));
 
獲取明天凌晨的時間戳
代碼:echo strtotime(date('Y-m-d',strtotime('+1 day')));
 
附上測試代碼:
echo strtotime('2012-11-2');
echo strtotime('2012-11-2 00:00:00');
echo strtotime(date('Y-m-d')),'
';
echo date('Y-m-d H:i:s',strtotime(date('Y-m-d')));
echo strtotime(date('Y-m-d',strtotime('+1 day')));
echo ( strtotime(date('Y-m-d',strtotime('+1 day'))) - strtotime(date('Y-m-d')) )/3600;
 
其它參考代碼:
 
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"));測試

相關文章
相關標籤/搜索