Analysis of PHP Method for Obtaining Zero Time Stamp of the Day

  • 2021-09-16 06:30:46
  • OfStack

In this paper, an example is given to describe the method of obtaining the zero timestamp of the day by PHP. Share it for your reference, as follows:

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 of the day and review the relevant knowledge of timestamp, which is summarized as follows:


<?php
header("Content-type:text/html;charset=utf-8");
// Set Beijing time as the default time zone 
date_default_timezone_set('PRC');
// Output the current time 
echo date("Y-m-d H:i:s",time()); //2016-08-11 10:30:32
// Get the timestamp of the early morning of the day 
$today = strtotime(date("Y-m-d"),time());
echo '<br>';
echo $today; //1470844800
echo '<br>';
// Verify that the timestamp of the early morning of the day is correct 
echo date("Y-m-d H:i:s",$today); //2016-08-11 00:00:00
echo '<br>';
// Of the day 24 Point timestamp 
$end = $today+60*60*24;
// Validate the current day's 24 Is the point timestamp correct 
echo date("Y-m-d H:i:s", $end); //2016-08-12 00:00:00
echo '<br>';
// Gets the timestamp of the zero point of the specified time 
$time = strtotime('2014-06-06');
echo '<br>';
echo $time; //1401984000
echo '<br>';
// Verify that it is a timestamp for the specified time 
echo date("Y-m-d H:i:s",$time); //2014-06-06 00:00:00
?>

PS: Here are some time and date related tools for your reference:

Online date/day calculator:
http://tools.ofstack.com/jisuanqi/date_jisuanqi

Online date calculator/difference days calculator:
http://tools.ofstack.com/jisuanqi/datecalc

Online Date-Day Difference Calculator:
http://tools.ofstack.com/jisuanqi/onlinedatejsq

Unix timestamp (timestamp) conversion tool:
http://tools.ofstack.com/code/unixtime

For more readers interested in PHP related contents, please check the topics on this site: "Summary of php Date and Time Usage", "Encyclopedia of PHP Array (Array) Operation Skills", "Introduction to php Object-Oriented Programming", "Introduction to php String (string) Usage", "Introduction to php+mysql Database Operation" and "Summary of Common Database Operation Skills of php"

I hope this article is helpful to everyone's PHP programming.


Related articles: