Code that displays the start and end points and timestamps for today, this month, last month, this year

Source: Internet
Author: User
Tags echo date
  1. /**

  2. Examples of PHP timestamp synthesis application
  3. Date:2013/2/19
  4. link:http://bbs.it-home.org
  5. */
  6. $t = time ();
  7. $t 1 = mktime (0,0,0,date ("M", $t), date ("D", $t), date ("Y", $t));
  8. $t 2 = mktime (0,0,0,date ("M", $t), 1,date ("Y", $t));
  9. $t 3 = mktime (0,0,0,date ("M", $t) -1,1,date ("Y", $t));
  10. $t 4 = mktime (0,0,0,1,1,date ("Y", $t));
  11. $e 1 = mktime (23,59,59,date ("M", $t), date ("D", $t), date ("Y", $t));
  12. $e 2 = mktime (23,59,59,date ("M", $t), date ("T"), Date ("Y", $t));
  13. $e 3 = mktime (23,59,59,date ("M", $t) -1,date ("T", $t 3), date ("Y", $t));
  14. $e 4 = mktime (23,59,59,12,31,date ("Y", $t));

  15. Test

  16. echo Date ("Current y-m-d h:i:s", $t). "$t
    ”;
  17. Echo Date ("Today's beginning y-m-d h:i:s", $t 1). "$t 1
    ”;
  18. Echo Date ("The beginning of this month y-m-d h:i:s", $t 2). "$t 2
    ”;
  19. echo Date ("Last month beginning y-m-d h:i:s", $t 3). "$t 3
    ”;
  20. Echo Date ("The beginning of this year y-m-d h:i:s", $t 4). "$t 4
    ”;
  21. Test
  22. Echo Date ("Today's End y-m-d h:i:s", $e 1). "$e 1
    ”;
  23. echo Date ("Y-m-d h:i:s" at the end of this month, $e 2). "$e 2
    ”;
  24. echo Date ("Last month end y-m-d h:i:s", $e 3). "$e 3
    ”;
  25. echo Date ("End of this year y-m-d h:i:s", $e 4). "$e 4
    ”;
  26. ?>

Copy Code

Output: Current 2011-05-24 15:42:55 1306222975 today beginning 2011-05-24 00:00:00 1306166400 this month beginning 2011-05-01 00:00:00 1304179200 last month beginning 2011- 04-01 00:00:00 1301587200 This year start 2011-01-01 00:00:00 1293811200 today end 2011-05-24 23:59:59 1306252799 this month end 2011-05-31 23:59:59 1306857599 last month 2011-04-30 23:59:59 1304179199 end of this year 2011-12-31 23:59:59 1325347199

  • Related Article

    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.