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 今天開(kāi)始時(shí)間戳)
//返回(昨天,今天和明天)的0點(diǎn)和23點(diǎn)59分59秒
function alldaytostr($startstr) {
$oneday_count = 3600 * 24; //一天有多少秒
//明天
$tomorrow_s = $startstr + $oneday_count; //明天開(kāi)始
$tomorrow_e = $tomorrow_s + $oneday_count - 1; //明天結(jié)束
//昨天
$yesterday_s = $startstr - $oneday_count; //昨天開(kāi)始
$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)天開(kāi)始時(shí)間
$btime = date('Y-m-d'.'00:00:00',time());
//轉(zhuǎn)換成“開(kāi)始”的時(shí)間戳
$btimestr = strtotime($btime);
var_dump(alldaytostr($btimestr));
?>
相關(guān)文章
PHP session文件獨(dú)占鎖引起阻塞問(wèn)題解決方法
這篇文章主要介紹了PHP session文件獨(dú)占鎖引起阻塞,本文講解PHP使用默認(rèn)文件會(huì)話處理器時(shí)容易導(dǎo)致的阻塞問(wèn)題解決方法,需要的朋友可以參考下2015-05-05
如何使用微信公眾平臺(tái)開(kāi)發(fā)模式實(shí)現(xiàn)多客服
其實(shí)微信公眾平臺(tái)的多客服功能已經(jīng)出來(lái)好久了,并且一出來(lái)的時(shí)候我就已經(jīng)為自己的公眾號(hào)實(shí)現(xiàn)了,原本以為大家都已經(jīng)會(huì)了,但是今天還是有人問(wèn)起這個(gè)多客服功能怎么使用,我找了下網(wǎng)上也沒(méi)什么好的教程,今天我就給大家發(fā)一篇比較簡(jiǎn)單易懂的教程吧2016-01-01
php 二維數(shù)組快速排序算法的實(shí)現(xiàn)代碼
這篇文章主要介紹了php 二維數(shù)組快速排序算法的實(shí)現(xiàn)代碼的相關(guān)資料,希望通過(guò)本文能幫助到大家,讓大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-10-10
php中通過(guò)smtp發(fā)郵件的類(lèi),測(cè)試通過(guò)
php中通過(guò)smtp發(fā)郵件的類(lèi),測(cè)試通過(guò)...2007-01-01

