Get this week, next week, this month, next month, this quarter date with PHP (pick)

Source: Internet
Author: User
Tags echo date
Get this week, last week, this month, last month, this quarter date (pick) with PHP

echo Date ("Ymd", Strtotime ("Now"), "\ n";??

echo Date ("Ymd", Strtotime ("1 week Monday")), "\ n";??

echo Date ("Ymd", Strtotime ("1 week Sunday")), "\ n";??

echo Date ("Ymd", Strtotime ("+0 Week Monday")), "\ n";??

echo Date ("Ymd", Strtotime ("+0 Week Sunday")), "\ n";??

??

??

What month is the date (' n ')??

Date ("W") What week of the week??

Date ("T") days of the month??

??

Echo '
Last week:
'; ??

echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M"), Date ("D")-date ("W") +1-7,date ("Y")), "\ n";??

echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), Date ("D")-date ("W") +7-7,date ("Y")), "\ n";??

Echo '
Week:
'; ??

echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M"), Date ("D")-date ("W") +1,date ("Y")), "\ n";??

echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), Date ("D")-date ("W") +7,date ("Y")), "\ n";??

??

Echo '
Last month:
'; ??

echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M") -1,1,date ("Y")), "\ n";??

echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), 0,date ("Y")), "\ n";??

Echo '
Month:
'; ??

echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M"), 1,date ("Y")), "\ n";??

echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), Date ("T"), Date ("Y")), "\ n";??

??

$getMonthDays = Date ("T", mktime (0, 0, 0,date (' n ') + (date (' n ')-1)%3,1,date ("Y")), or//the last month of the quarter??

Echo '
This quarter:
'; ??

echo Date (' y-m-d h:i:s ', mktime (0, 0, 0,date (' n ')-(date (' n ')-1)%3,1,date (' Y ')), "\ n";??

echo Date (' y-m-d h:i:s ', Mktime (23,59,59,date (' n ') + (date (' n ')-1)%3, $getMonthDays, date (' Y '))), "\ n";?



This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/mlks_2008/archive/2009/08/05/4411053.aspx

  • 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.