Code that displays the start, end, and timestamp of today, this month, last month, and this year

Source: Internet
Author: User
Code that displays the start, end, and timestamp of today, this month, last month, and this year

  1. /**

  2. Example of a php timestamp combination application
  3. Date: 2013/2/19
  4. Link: http://bbs.it-home.org
  5. */
  6. $ T = time ();
  7. $ T1 = mktime (0, 0, 0, date ("m", $ t), date ("d", $ t), date ("Y", $ t ));
  8. $ T2 = mktime (0, 0, 0, date ("m", $ t), 1, date ("Y", $ t ));
  9. $ T3 = mktime (, 0, date ("m", $ t)-, date ("Y", $ t ));
  10. $ T4 = mktime (, 1, date ("Y", $ t ));
  11. $ E1 = mktime (, 59, date ("m", $ t), date ("d", $ t), date ("Y", $ t ));
  12. $ E2 = mktime (, 59, date ("m", $ t), date ("t"), date ("Y", $ t ));
  13. $ E3 = mktime (, 59, date ("m", $ t)-1, date ("t", $ t3), date ("Y ", $ t ));
  14. $ E4 = mktime (, 31, date ("Y", $ t ));

  15. // Test

  16. Echo date ("current Y-m-d H: I: s", $ t). "$ t
    ";
  17. Echo date ("Today's start point Y-m-d H: I: s", $ t1). "$ t1
    ";
  18. Echo date ("starting point of this month Y-m-d H: I: s", $ t2). "$ t2
    ";
  19. Echo date ("starting from last month Y-m-d H: I: s", $ t3). "$ t3
    ";
  20. Echo date ("This year's start point Y-m-d H: I: s", $ t4). "$ t4
    ";
  21. // Test
  22. Echo date ("end today Y-m-d H: I: s", $ e1). "$ e1
    ";
  23. Echo date ("end of this month Y-m-d H: I: s", $ e2). "$ e2
    ";
  24. Echo date ("end of last month Y-m-d H: I: s", $ e3). "$ e3
    ";
  25. Echo date ("end of this year Y-m-d H: I: s", $ e4). "$ e4
    ";
  26. ?>

Output result: currently 15:42:55 1306222975 today's start point 00:00:00 1306166400 this month's start point 00:00:00 1304179200 last month's start point 00:00:00 1301587200 this year's start point 00:00:00 1293811200 today's end point 23:59:59 1306252799 last month's end point 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.