Home > Backend Development > PHP Tutorial > How to get the zero o'clock timestamp of the current day in PHP

How to get the zero o'clock timestamp of the current day in PHP

小云云
Release: 2023-03-22 13:40:01
Original
8801 people have browsed it

This article mainly introduces the method of obtaining the zero-point timestamp of the day in PHP, and analyzes the common timestamp conversion and operation related operation skills of PHP in the form of examples. Friends who need it can refer to it. I hope it can help everyone.

In today's project, what I want to see every day is all the information of the day, so I want to get the timestamp at zero o'clock that day. Review the relevant knowledge of timestamps. The summary is as follows:


<?php
header("Content-type:text/html;charset=utf-8");
//设置北京时间为默认时区
date_default_timezone_set(&#39;PRC&#39;);
//输出当前时间
echo date("Y-m-d H:i:s",time()); //2016-08-11 10:30:32
//获得当日凌晨的时间戳
$today = strtotime(date("Y-m-d"),time());
echo &#39;<br>&#39;;
echo $today; //1470844800
echo &#39;<br>&#39;;
//验证当日凌晨的时间戳是否正确
echo date("Y-m-d H:i:s",$today); //2016-08-11 00:00:00
echo &#39;<br>&#39;;
//当天的24点时间戳
$end = $today+60*60*24;
//验证当天的24点时间戳是否正确
echo date("Y-m-d H:i:s", $end); //2016-08-12 00:00:00
echo &#39;<br>&#39;;
//获得指定时间的零点的时间戳
$time = strtotime(&#39;2014-06-06&#39;);
echo &#39;<br>&#39;;
echo $time; //1401984000
echo &#39;<br>&#39;;
//验证是否是指定时间的时间戳
echo date("Y-m-d H:i:s",$time); //2014-06-06 00:00:00
?>
Copy after login

Related recommendations:

How to use php timestamp

How to get the current timestamp in php accurate to milliseconds

PHP timestamp and date conversion example sharing

The above is the detailed content of How to get the zero o'clock timestamp of the current day in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template