PHP code to display the start/end timestamps of today, this month, last month, and this year_PHP Tutorial

WBOY
Release: 2016-07-21 15:29:16
Original
938 people have browsed it

$t = time();
$t1 = mktime(0,0,0,date(“m”,$t),date(“d”,$t),date(“Y”,$t));
$t2 = mktime(0,0,0,date(“m”,$t),1,date(“Y”,$t));
$t3 = mktime(0,0,0,date(“m”,$t)-1,1,date(“Y”,$t));
$t4 = mktime(0,0,0,1,1,date(“Y”,$t));
$e1 = mktime(23,59,59,date(“m”,$t),date(“d”,$t),date(“Y”,$t));
$e2 = mktime(23,59,59,date(“m”,$t),date(“t”),date(“Y”,$t));
$e3 = mktime(23,59,59,date(“m”,$t)-1,date(“t”,$t3),date(“Y”,$t));
$e4 = mktime(23,59,59,12,31,date(“Y”,$t));
//测试
echo date(“当前 Y-m-d H:i:s”,$t).” $t
”;
echo date(“今天起点 Y-m-d H:i:s”,$t1).” $t1
”;
echo date(“今月起点 Y-m-d H:i:s”,$t2).” $t2
”;
echo date(“上月起点 Y-m-d H:i:s”,$t3).” $t3
”;
echo date(“今年起点 Y-m-d H:i:s”,$t4).” $t4
”;
//测试
echo date(“今天终点 Y-m-d H:i:s”,$e1).” $e1
”;
echo date(“今月终点 Y-m-d H:i:s”,$e2).” $e2
”;
echo date(“上月终点 Y-m-d H:i:s”,$e3).” $e3
”;
echo date(“今年终点 Y-m-d H:i:s”,$e4).” $e4
”;
结果:
当前 2011-05-24 15:42:55 1306222975
今天起点 2011-05-24 00:00:00 1306166400
今月起点 2011-05-01 00:00:00 1304179200
上月起点 2011-04-01 00:00:00 1301587200
今年起点 2011-01-01 00:00:00 1293811200
今天终点 2011-05-24 23:59:59 1306252799
今月终点 2011-05-31 23:59:59 1306857599
上月终点 2011-04-30 23:59:59 1304179199
今年终点 2011-12-31 23:59:59 1325347199

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/323481.htmlTechArticle$t = time(); $t1 = mktime(0,0,0,date(“m”,$t),date(“d”,$t),date(“Y”,$t)); $t2 = mktime(0,0,0,date(“m”,$t),1,date(“Y”,$t)); $t3 = mktime(0,0,0,date(“m”,$t)-1,1...
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