国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php時間戳轉換的示例

2024-05-04 23:22:34
字體:
來源:轉載
供稿:網友

以下例子得出結果:

復制代碼 代碼如下:


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

//昨天,今天和明天的日期轉換   
//($startstr 今天開始時間戳)
//返回(昨天,今天和明天)的0點和23點59分59秒
function alldaytostr($startstr) {
 $oneday_count = 3600 * 24;  //一天有多少秒
 //明天
 $tomorrow_s = $startstr + $oneday_count;    //明天開始
 $tomorrow_e = $tomorrow_s + $oneday_count - 1;  //明天結束
 //昨天
 $yesterday_s = $startstr - $oneday_count;  //昨天開始
 $yesterday_e = $startstr - 1;   //昨天結束
 //今天結束
 $today_e = $tomorrow_s - 1;
 //昨天、今天和明天 0點和當天23點59分59秒合并成數組
 $allday_array = array('yesterday' => array($yesterday_s, $yesterday_e),
  'today' => array($startstr, $today_e),
  'tomorrow' => array($tomorrow_s, $tomorrow_e));
 return $allday_array;
}
//當天開始時間
$btime = date('Y-m-d'.'00:00:00',time());
//轉換成“開始”的時間戳
$btimestr = strtotime($btime);
var_dump(alldaytostr($btimestr));

?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 高淳县| 钦州市| 滨州市| 平利县| 东兰县| 浦东新区| 霍邱县| 辽宁省| 交城县| 应用必备| 恩平市| 广南县| 马边| 扬州市| 隆回县| 大英县| 黎平县| 策勒县| 夏河县| 香格里拉县| 宜阳县| 锡林浩特市| 花垣县| 肇州县| 册亨县| 鸡泽县| 琼海市| 凤城市| 武穴市| 大港区| 岱山县| 青海省| 灵寿县| 河南省| 南岸区| 湖口县| 清涧县| 焦作市| 商南县| 吉木乃县| 廉江市|