PHP Gets the date and week of the next seven days

Source: Internet
Author: User
Tags sprintf

PHP Gets the date and week code for the next seven days

for ($i =4; $i <8; $i + +) {

$dateArray [$i]=date (' y-m-d ', strtotime (date (' y-m-d '). ' + '. $i. ' Day '))

};

$b =array ();

foreach ($dateArray as $key = = $value) {

$b []=array (' id ' = = $key, ' date ' = $value)

};

foreach ($b as $k = = $v) {

$b [$k] [' Week ']=get_week ($v [' Date ']);

$b [$k] [' Date ']=substr ($v [' Date '],5);

}

function Get_week ($date) {

$date _str=date (' y-m-d ', Strtotime ($date));
$arr =explode ("-", $date _str);
$year = $arr [0];
$month =sprintf ('%02d ', $arr [1]);
$day =sprintf ('%02d ', $arr [2]);
$hour = $minute = $second = 0;
$strap = Mktime ($hour, $minute, $second, $month, $day, $year);
$number _wk=date ("W", $strap);
$WEEKARR =array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
return $WEEKARR [$number _WK];

}

PHP Gets the date and week of the next seven days

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.