Time and date Formatting Function in php-PHP source code

Source: Internet
Author: User
Here we will introduce the time and date formatting of the three functions, all of which are customized in the format of another week. For more information, see. Here we will introduce the time and date formatting of the three functions, all of which are customized in the format of another week. For more information, see.

Script ec (2); script

The Code is as follows:

Function format_date ($ STRING1)
{
$ STRING1 = str_replace ("-0", "-", $ STRING1 );
$ STR = strtok ($ STRING1 ,"-");
$ STRING2 = $ STR. "year ";
$ STR = strtok ("-");
$ STRING2. = $ STR. "month ";
$ STR = strtok ("");
$ STRING2. = $ STR. "day ";
Return $ STRING2;
}

Function format_date_short1 ($ STRING1)
{
$ STRING1 = str_replace ("-0", "-", $ STRING1 );
$ STR = strtok ($ STRING1 ,"-");
$ STRING2 = $ STR. "year ";
$ STR = strtok ("-");
$ STRING2. = $ STR. "month ";
Return $ STRING2;
}

Function format_date_short2 ($ STRING1)
{
$ STRING1 = str_replace ("-0", "-", $ STRING1 );
$ STR = strtok ($ STRING1 ,"-");
$ STR = strtok ("-");
$ STRING2. = $ STR. "month ";
$ STR = strtok ("");
$ STRING2. = $ STR. "day ";
Return $ STRING2;
}

Function format_date_short3 ($ STRING1)
{
$ STRING1 = str_replace ("-0", "-", $ STRING1 );
$ STR = strtok ($ STRING1 ,"-");
$ STRING2. = $ STR. "year ";
Return $ STRING2;
}

Function format_date_number ($ STRING1)
{
$ STRING1 = str_replace ("-0", "-", $ STRING1 );
$ STR = strtok ($ STRING1 ,"-");
$ STRING2 = $ STR;
$ STR = strtok ("-");
$ STRING2. = strlen ($ STR) = 1? "0". $ STR: $ STR;
$ STR = strtok ("");
$ STRING2. = strlen ($ STR) = 1? "0". $ STR: $ STR;
Return $ STRING2;
}

Function get_week ($ STRING)
{
Switch (date ("w", strtotime ($ STRING )))
{
Case 0:
Return "day ";
Case 1:
Return "1 ";
Case 2:
Return "2 ";
Case 3:
Return "3 ";
Case 4:
Return "4 ";
Case 5:
Return "5 ";
Case 6:
Return "6 ";
}
}

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.