如何在php中对时间戳进行转换

介绍

这篇文章将为大家详细讲解有关如何在php中对时间戳进行转换,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

代码如下:


数组(3){[“yesterday"]=比;(2)数组{[0]=比;int(1395874800)[1]=比;int (1395961199)} (“today")=比;(2)数组{[0]=比;int(1395961200)[1]=比;int (1396047599)} (“tomorrow")=比;(2)数组{[0]=比;int(1396047600)[1]=比;int (1396133999)}}

代码如下:


& lt; ? php

//昨天,今天和明天的日期转换,,,
//($ startstr今天开始时间戳)
//返回(昨天,今天和明天)的0点和23点59分59秒
函数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=阵列(& # 39;昨天# 39;=比;数组(yesterday_s, yesterday_e美元),
,, & # 39;整理# 39;=比;数组(startstr, today_e美元),
,, & # 39;明天# 39;=比;阵列(tomorrow_s, tomorrow_e美元));
,返回allday_array美元;
}
//当天开始时间
$ btime=日期(& # 39;Y-m-d& # 39;强生# 39;就是# 39;,时间());
//转换成“开始”的时间戳
$ btimestr=strtotime ($ btime);
var_dump (alldaytostr (btimestr美元));

?在

关于如何在php中对时间戳进行转换就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看的到。

如何在php中对时间戳进行转换