php 某一天时间凌晨,PHP获得今天 天凌晨时间戳的例子
在這里我們可以利用strtotime函數(shù)與date函數(shù)同時(shí)使用來獲取了,例子非常的簡單在此我就不介紹其它的了,直接上代碼。
PHP獲得今天凌晨時(shí)間戳,百度了一下,沒看見有,也可能是我理解錯(cuò)了。
直接上代碼:
比如,今天是2102年11月2號,那么php要獲取2102年11月2號的時(shí)間戳是怎么辦的呢?
代碼:echo strtotime(date('Y-m-d')),'
';
獲取明天凌晨的時(shí)間戳
代碼:echo strtotime(date('Y-m-d',strtotime(' 1 day'))),'
';
最后再附一串代碼
echo "今天:".date("Y-m-d")."
";
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 "一周零兩天四小時(shí)兩秒后:".date("Y-m-d G:H:s",strtotime(" 1 week 2 days 4 hours 2 seconds")). "
";
echo "下個(gè)星期四:".date("Y-m-d",strtotime("next Thursday")). "
";
echo "上個(gè)周一:".date("Y-m-d",strtotime("last Monday"))."
";
echo "一個(gè)月前:".date("Y-m-d",strtotime("last month"))."
";
echo "一個(gè)月后:".date("Y-m-d",strtotime(" 1 month"))."
";
echo "十年后:".date("Y-m-d",strtotime(" 10 year"))."
";
strtotime()函數(shù)的作用是將日期時(shí)間描述解析為 Unix 時(shí)間戳
int strtotime? ( string time [, int now] )
?>
總結(jié)
以上是生活随笔為你收集整理的php 某一天时间凌晨,PHP获得今天 天凌晨时间戳的例子的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php layui实现添加input,L
- 下一篇: php h5用户信息,【php】PHP怎