Home php教程 php手册 php时间戳转换的示例

php时间戳转换的示例

Jun 06, 2016 pm 08:23 PM

PHP获

以下例子得出结果:

复制代码 代码如下:


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) } }

复制代码 代码如下:


//昨天,,今天和明天的日期转换   
//($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));

?>

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)