$t = time ();
$t 1 = mktime (0,0,0,date ("M", $t), date ("D", $t), date ("Y", $t));
$t 2 = mktime (0,0,0,date ("M", $t), 1,date ("Y", $t));
$t 3 = mktime (0,0,0,date ("M", $t) -1,1,date ("Y", $t));
$t 4 = mktime (0,0,0,1,1,date ("Y", $t));
$e 1 = mktime (23,59,59,date ("M", $t), date ("D", $t), date ("Y", $t));
$e 2 = mktime (23,59,59,date ("M", $t), date ("T"), Date ("Y", $t));
$e 3 = mktime (23,59,59,date ("M", $t) -1,date ("T", $t 3), date ("Y", $t));
$e 4 = mktime (23,59,59,12,31,date ("Y", $t));
Test
echo Date ("Current y-m-d h:i:s", $t). "$t <br>";
Echo Date ("Today's beginning y-m-d h:i:s", $t 1). "$t 1<br>";
echo Date ("Beginning of this month y-m-d h:i:s", $t 2). "$t 2<br>";
echo Date ("Beginning of last month y-m-d h:i:s", $t 3). "$t 3<br>";
echo Date ("Beginning of this year y-m-d h:i:s", $t 4). "$t 4<br>";
Test
Echo Date ("Today's End y-m-d h:i:s", $e 1). "$e 1<br>";
Echo Date ("The end of this month y-m-d h:i:s", $e 2). "$e 2<br>";
echo Date ("End of last month y-m-d h:i:s", $e 3). "$e 3<br>";
Echo Date ("The end of this year y-m-d h:i:s", $e 4). "$e 4<br>";
Results:
Current 2011-05-24 15:42:55 1306222975
Today's beginning 2011-05-24 00:00:00 1306166400
Beginning of this month 2011-05-01 00:00:00 1304179200
Beginning of last month 2011-04-01 00:00:00 1301587200
Beginning of this year 2011-01-01 00:00:00 1293811200
Today's End 2011-05-24 23:59:59 1306252799
End of this month 2011-05-31 23:59:59 1306857599
Last month's End 2011-04-30 23:59:59 1304179199
End of this year 2011-12-31 23:59:59 1325347199
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.