PHP Gets the day of the Week instance program _php Tutorial

Source: Internet
Author: User
In PHP we want to get today is the day of the week can be directly using the DATE function to operate, the following I will give you a summary of the specific methods of operation, I hope this method for friends to help.

PHP Gets the week method Daquan simple introduction, PHP week to get code:

The code is as follows Copy Code

1 Date ("L");

2//data can get English for weeks like Sunday

3 Date ("W");

4//This can get digital weeks like 123, note 0 is Sunday

Get Chinese Weekday:

The code is as follows Copy Code

1 $weekarray =array ("Day", "one", "two", "three", "four", "Five", "VI");

2//define an array first

3 echo "Week". $weekarray [Date ("W")];

Gets the specified date:

The code is as follows Copy Code

1 $weekarray =array ("Day", "one", "two", "three", "four", "Five", "VI");

2 echo "Week". $weekarray [Date ("W", "2011-11-11")];

An example of your own use

The code is as follows Copy Code


PHP get today is the day of the week
function Getweek ($unixTime = ") {
$unixTime =is_numeric ($unixTime)? $unixTime: Time ();
$weekarray =array (' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' VI ');
Return ' Week '. $weekarray [Date (' W ', $unixTime)];
}
Echo Getweek ();

Or

The code is as follows Copy Code

function Getweek () {
$week = Date ("W");
Switch ($week) {
Case 1:
return "Monday";
Break
Case 2:
return "Tuesday";
Break
Case 3:
return "Wednesday";
Break
Case 4:
return "Thursday";
Break
Case 5:
return "Friday";
Break
Case 6:
return "Saturday";
Break
Case 0:
return "Sunday";
Break
}
}
echo "Today is:". Getweek ();
?>

http://www.bkjia.com/PHPjc/632809.html www.bkjia.com true http://www.bkjia.com/PHPjc/632809.html techarticle in PHP we want to get today is the day of the week can be directly using the DATE function to operate, the following I will give you a summary of the specific methods of operation, I hope this method for your friends to help ...

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