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