PHP return today is the first few weeks

Source: Internet
Author: User

/**
* Return date is the first few weeks
* @param number $style style
* @return Returns a string or a value for calculation
*/
function Get_day_week ($data = false, $style = 0)
{
if ($data) {
$data = $data;
}else{
$data = Date (' y-m-d ');
}
$DAYF = Date (' W ', Strtotime (date (' y-m-01 ')));
$wk _day=date (' W ', Strtotime ($data)); Get today is the day of the week
$date _now=date (' J ', Strtotime ($data)); What's the date today?
$wkday _ar=array (' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' VI '); Normalize the expression of the Sunday
$cal _result=ceil (($date _now+ $DAYF-1)/7); Calculation is the first few weeks
if ($style ==1) {
$rs = Date ("Y-year N-month J-Day"). "Week". $wkday _ar[$wk _day]. "-This month". $cal _result. $wkday _ar[$wk _day];
}
else if ($style ==2) {
$rs = "Today is the first of the month". $wkday _ar[$cal _result]. " Weeks ". $wkday _ar[$wk _day];
}else{
$rs = Array ("Cal_result" and "_result" and "wk_day" = $wk _day);
}
return $rs;
}

PHP return today is the first few weeks

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.