Time and date format function in PHP

Source: Internet
Author: User
Tags strlen strtok time and date
The code is as follows Copy Code

function Format_date ($STRING 1)
{
$STRING 1 = str_replace ("-0", "-", $STRING 1);
$STR = Strtok ($STRING 1, "-");
$STRING 2 = $STR. " Years ";
$STR = Strtok ("-");
$STRING 2. = $STR. " Month ";
$STR = Strtok ("");
$STRING 2. = $STR. " Day ";
return $STRING 2;
}

Function Format_date_short1 ($STRING 1)
{
        $STRING 1 = str_replace ("-0", "-", $STRING 1);
        $STR = strtok ($STRING 1, "-");
        $STRING 2 = $STR. " Years ";
        $STR = strtok ("-");
        $STRING 2. = $STR. " Month ";
        return $STRING 2;
}

function Format_date_short2 ($STRING 1)
{
$STRING 1 = str_replace ("-0", "-", $STRING 1);
$STR = Strtok ($STRING 1, "-");
$STR = Strtok ("-");
$STRING 2. = $STR. " Month ";
$STR = Strtok ("");
$STRING 2. = $STR. " Day ";
return $STRING 2;
}

function Format_date_short3 ($STRING 1)
{
$STRING 1 = str_replace ("-0", "-", $STRING 1);
$STR = Strtok ($STRING 1, "-");
$STRING 2. = $STR. " Years ";
return $STRING 2;
}

function Format_date_number ($STRING 1)
{
$STRING 1 = str_replace ("-0", "-", $STRING 1);
$STR = Strtok ($STRING 1, "-");
$STRING 2 = $STR;
$STR = Strtok ("-");
$STRING 2. = strlen ($STR) = = 1? "0". $STR: $STR;
$STR = Strtok ("");
$STRING 2. = strlen ($STR) = = 1? "0". $STR: $STR;
return $STRING 2;
}

function Get_week ($STRING)
{
Switch (Date ("W", Strtotime ($STRING))
{
Case 0:
Return "Day";
Case 1:
return "one";
Case 2:
return "two";
Case 3:
return "three";
Case 4:
return "four";
Case 5:
return "five";
Case 6:
Return "Six";
}
}

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.