PHP shows today is the day of the week with the code for each day of the year

Source: Internet
Author: User

PHP shows today is the day of the week with the code for each day of the year

Public Function Getpart ($part) {
$source = $this->timestamp;
Switch ($part)
{
Case ' yy ': $result = intval (Date ("Y", $source)); Break Years
Case ' mm ': $result = intval (Date ("M", $source)); Break Month
Case ' dd ': $result = intval (Date ("D", $source)); Break Day
Case ' W ': $result = intval (Date ("N", $source)); Break Week [1-7] "1" Expression Monday
Case ' CW ': $index = Date ("N", $source); Chinese Week
$week _array = Array (' 1 ' => ' one ', ' 2 ' => ' II ', ' 3 ' => ' III ', ' 4 ' => ' IV ', ' 5 ' => ' V ', ' 6 ' => ' Six ', ' 7 ' => ' Day ');
$result = ' Week '. $week _array[$index];

Break
Case ' h ': $result = intval (Date ("H", $source)); Break When
Case ' m ': $result = intval (Date ("I", $source)); Break Part
Case ' s ': $result = intval (Date ("s", $source)); Break Seconds
Case ' yw ': $result = intval (Date ("W", $source)); Break The first few weeks of the year
Case ' yd ': $result = intval (Date ("Z", $source)); Break The first day of the year
Default://All
$week _array = Array (' 1 ' => ' one ', ' 2 ' => ' II ', ' 3 ' => ' III ', ' 4 ' => ' IV ', ' 5 ' => ' V ', ' 6 ' => ' Six ', ' 7 ' => ' Day ');
$result = Array (
' yy ' => intval (date ("Y", $source)),//year
' mm ' => intval (date ("M", $source)),//month
' DD ' => intval (date ("D", $source)),//day
' W ' => intval (date ("N", $source)),//week [1-7] "1" means Monday
' CW ' => ' Week '. $week _array[date ("N", $source)],//Chinese week
' H ' => intval (date ("H", $source)),//
' m ' => intval (date ("I", $source)),//min
' s ' => intval (date ("s", $source)),//sec
);
Break
}

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.