PHP displays the start and end timestamps of today, this month, next month, and this year

Source: Internet
Author: User
Tags echo date
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

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.