PHP displays the code for today today last month and this year's starting and ending timestamp

  • 2020-05-07 19:17:22
  • OfStack

$t = time();
$t1 = mktime (0, 0, date (" m ", $t), date (" d ", $t), date (" Y ", $t));
$t2 = mktime (0, 0, date (" m ", $t), 1, date (" Y ", $t));
$t3 = mktime (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));
/ / test
echo date(" current Y-m-d H:i:s ",$t) < br > ";
echo date(" starting point today Y-m-d H:i:s ",$t1) < br > ";
echo date(" starting point for today Y-m-d H:i:s ",$t2) < br > ";
echo date(" last month starting point Y-m-d H:i:s ",$t3) < br > ";
echo date(" starting point for this year Y-m-d H:i:s ",$t4) < br > ";
/ / test
echo date(" end of the day Y-m-d H:i:s ",$e1) < br > ";
echo date(" end of the month Y-m-d H:i:s ",$e2) < br > ";
echo date(" end of last month Y-m-d H:i:s ",$e3) < br > ";
echo date(" year ending Y-m-d H:i:s ",$e4) < br > ";
Results:
Current 2011-05-24 15:42:55 1306222975
Starting today 2011-05-24 00:00:00 1306166400
The starting point of this month is 1304179200
The starting point of last month is 1301587200
The starting point of this year is 1293811200
End of the day 2011-05-24 23:59:59 1306252799
End of this month 2011-05-31 23:59:59 1306857599
End of last month: 2011-04-30 23:59:59
End of the year: 2011-12-31 23:59:59

Related articles: