這篇文章將為大家詳細(xì)講解有關(guān)如何在php中對(duì)時(shí)間戳進(jìn)行轉(zhuǎn)換,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。
代碼如下:
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) } }
復(fù)制代碼 代碼如下:
<?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)于如何在php中對(duì)時(shí)間戳進(jìn)行轉(zhuǎn)換就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
當(dāng)前名稱:如何在php中對(duì)時(shí)間戳進(jìn)行轉(zhuǎn)換-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://www.rwnh.cn/article12/cojjgc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、外貿(mào)建站、面包屑導(dǎo)航、定制網(wǎng)站、域名注冊、網(wǎng)站維護(hù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容