PHP displays the start and end timestamp of today, this month, last month, and this year. PHP displays the start and end timestamp of today, this month, last month, and this year $ t & nbsp; & nbsp; time (); $ t1 & nbsp; mktime (0, 0, date (m, $ t), date (d, $ t), date (y php displays the start and end timestamp of today, this month, last month, and this year
PHP displays the start and end timestamps of today, this month, last month, and this year
$ 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, date ("m", $ t)-, 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 (, 31, date ("Y", $ t ));
// Test
Echo date ("current Y-m-d H: I: s", $ t). "$ t
";
Echo date ("Today's start point Y-m-d H: I: s", $ t1). "$ t1
";
Echo date ("starting point Y-m-d H: I: s", $ t2). "$ t2
";
Echo date ("Starting from last month Y-m-d H: I: s", $ t3). "$ t3
";
Echo date ("starting from Y-m-d H: I: s", $ t4). "$ t4
";
// Test
Echo date ("End today Y-m-d H: I: s", $ e1). "$ e1
";
Echo date ("end of this month Y-m-d H: I: s", $ e2). "$ e2
";
Echo date ("last month end Y-m-d H: I: s", $ e3). "$ e3
";
Echo date ("end of this year Y-m-d H: I: s", $ e4). "$ e4
";
Result:
Currently 15:42:55 1306222975
Starting from 00:00:00 1306166400
Starting from 00:00:00 1304179200
Starting from last month 00:00:00 1301587200
Starting from 00:00:00 this year, 1293811200
End of today: 23:59:59 1306252799
End of this month: 23:59:59 1306857599
Last month's endpoint 23:59:59 1304179199
End of this year 23:59:59 1325347199