PHP processing date and time (php author tutorial) _ PHP Tutorial

Source: Internet
Author: User
PHP processing date and time (php author tutorial ). This tutorial describes how to obtain the formatted date and time as follows. Process UNIX timestamps. Obtain date and time information. Date calculation. Verify the validity of the date. Php Tutorial processing this tutorial is mainly about three points as follows to get the formatted date and time. Process UNIX timestamps. Obtain date and time information. Date calculation. Verify the validity of the date.

Php Tutorial processing date and time (php author tutorial)
/*
This tutorial focuses on the following three points:

Obtain the formatted date and time.
Process unix timestamps.
Obtain date and time information.
Date calculation.
Verify the validity of the date.
*/
// Obtain the formatted date and time

Echo"Format the current time
";
Echo date ('Y-m-J ');
Echo"
";
Echo"
";

Echo "today is the day of the Year". date ('Z'). "day ";
Echo"
";
Echo"
";

Echo date ('m webpage effect, y l ');
Echo"
";
Echo"
";

Echo "program execution time:". date ('H: I: s ');

// Process the unix timestamp.

Echo "timestamp". mktime (,). "the corresponding date is :";
Echo"
";

Echo date ("m-d-y", mktime ));
Echo "";
Echo"
";

$ Day = 1;
Echo "timestamp". mktime (, $ day +). "the corresponding date is:
";
Echo date ("y-m-d", mktime (, $ day + ));
Echo "";

// Obtain the date and time information.

$ Time = mktime (20, 0 );

Echo"Date: ". date (" y-m-d h: I: s ", $ time )."";
Echo"
";

Echo"

";
Echo "the date information is as follows :";
Echo"
";

$ Date = getdate ($ time );
Print_r ($ date );

// Calculate the date.

$ Day = 1;
$ Month = 10;
$ Year = 1949;

$ National_unix = mktime (0, 0, 0, $ month, $ day, $ year );
$ Now_unix = time ();
$ National_time = $ now_unix-$ national_unix;

$ National_day_year = floor ($ national_time/(365*24*60*60 ));
$ National_day_day = floor ($ national_time/(24*60*60 ));

Echo "www. bKjia. c0m 2008 already". $ National_day_year ."Year ";
Echo "";

Echo "2008 already". $ National_day_day ."Day"

// Verify the validity of the date.

If (checkdate (9, 28, 1980 ))
{
Echo "7,22, 1978:". "This is a correct date format ";
}
Else
{
Echo "this is not a correct date format ";
}

Echo"
";
Echo "";
Echo"
";

If (checkdate (9, 99, 1999 ))
{
Echo "this is a correct date format ";
}
Else
{
Echo "9,99, 1999:". "This is not a correct date format ";
}

/*
In this tutorial, I mainly talked about the basic php date and time tutorials, which are useful for beginners of php.
*/
?>

Bytes. Process UNIX timestamps. Obtain date and time information. Date calculation. Verify the validity of the date. Php Tutorial processing...

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.