php時(shí)間戳轉(zhuǎn)換的示例
以下例子得出結(jié)果:
array(3) { ["yesterday"]=> array(2) { [0]=> int(1395874800) [1]=> int(1395961199) } ["today"]=> array(2) { [0]=> int(1395961200) [1]=> int(1396047599) } ["tomorrow"]=> array(2) { [0]=> int(1396047600) [1]=> int(1396133999) } }
<?php
//昨天,今天和明天的日期轉(zhuǎn)換
//($startstr 今天開始時(shí)間戳)
//返回(昨天,今天和明天)的0點(diǎn)和23點(diǎn)59分59秒
function alldaytostr($startstr) {
$oneday_count = 3600 * 24; //一天有多少秒
//明天
$tomorrow_s = $startstr + $oneday_count; //明天開始
$tomorrow_e = $tomorrow_s + $oneday_count - 1; //明天結(jié)束
//昨天
$yesterday_s = $startstr - $oneday_count; //昨天開始
$yesterday_e = $startstr - 1; //昨天結(jié)束
//今天結(jié)束
$today_e = $tomorrow_s - 1;
//昨天、今天和明天 0點(diǎn)和當(dāng)天23點(diǎn)59分59秒合并成數(shù)組
$allday_array = array('yesterday' => array($yesterday_s, $yesterday_e),
'today' => array($startstr, $today_e),
'tomorrow' => array($tomorrow_s, $tomorrow_e));
return $allday_array;
}
//當(dāng)天開始時(shí)間
$btime = date('Y-m-d'.'00:00:00',time());
//轉(zhuǎn)換成“開始”的時(shí)間戳
$btimestr = strtotime($btime);
var_dump(alldaytostr($btimestr));
?>
相關(guān)文章
ThinkPHP5.1框架頁面跳轉(zhuǎn)及修改跳轉(zhuǎn)頁面模版示例
這篇文章主要介紹了ThinkPHP5.1框架頁面跳轉(zhuǎn)及修改跳轉(zhuǎn)頁面模版,結(jié)合實(shí)例形式分析了thinkPHP5.1框架進(jìn)行頁面跳轉(zhuǎn)及修改跳轉(zhuǎn)模板相關(guān)操作技巧,需要的朋友可以參考下2019-05-05tp5修改(實(shí)現(xiàn)即點(diǎn)即改)
今天小編就為大家分享一篇tp5修改(實(shí)現(xiàn)即點(diǎn)即改),具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10Thinkphp使用Zxing擴(kuò)展庫解析二維碼內(nèi)容圖文講解
這篇文章主要介紹了Thinkphp使用Zxing擴(kuò)展庫解析二維碼內(nèi)容圖文講解,圖文步驟講解的很清晰,有需要的同學(xué)可以跟著小編一起來學(xué)習(xí)下2021-03-03php簡單的留言板與回復(fù)功能具體實(shí)現(xiàn)
留言板是在剛接觸php時(shí)用來學(xué)習(xí)的一個(gè)簡單的應(yīng)用例子了,今天我再給初學(xué)php的朋友提供一個(gè)完整的php留言板的全部制作過程,希望對你會(huì)有幫助2014-02-02