PHP Displays the start/end time stamp for today, this month, next month, this year

Source: Internet
Author: User
PHP Displays the start/end time stamp for today, this month, last month, this year
PHP Displays the start/end time stamp for today, this month, last month, this year
$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
";
Echo Date ("Today's beginning y-m-d h:i:s", $t 1). "$t 1
";
Echo Date ("The beginning of this month y-m-d h:i:s", $t 2). "$t 2
";
echo Date ("Last month beginning y-m-d h:i:s", $t 3). "$t 3
";
Echo Date ("The beginning of this year y-m-d h:i:s", $t 4). "$t 4
";
Test
Echo Date ("Today's End y-m-d h:i:s", $e 1). "$e 1
";
echo Date ("Y-m-d h:i:s" at the end of this month, $e 2). "$e 2
";
echo Date ("Last month end y-m-d h:i:s", $e 3). "$e 3
";
echo Date ("End of this year y-m-d h:i:s", $e 4). "$e 4
";
Results:
Current 2011-05-24 15:42:55 1306222975
Today's beginnings 2011-05-24 00:00:00 1306166400
The beginning of this month 2011-05-01 00:00:00 1304179200
Last month's beginnings 2011-04-01 00:00:00 1301587200
This year's beginnings 2011-01-01 00:00:00 1293811200
End of day 2011-05-24 23:59:59 1306252799
The end of this month 2011-05-31 23:59:59 1306857599
End of last month 2011-04-30 23:59:59 1304179199
End of year 2011-12-31 23:59:59 1325347199
  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.