PHP date and time, PHP date and time _ PHP Tutorial

Source: Internet
Author: User
PHP date and time, PHP date and time. PHP date and time, PHP date and time 1, datestringdate (string $ format [, int $ timestamp]) echodate (Y ). br; 2016 echodate (y ). br; 16echo ------ br; echo PHP date and time, PHP date and time

1. date

string date ( string $format [, int $timestamp ] )

Echo date ('Y ').'
'; // 2016
Echo date ('Y ').'
'; // 16

Echo '------
';

Echo date ('M ').'
'; // 03
Echo date ('M ').'
'; // Mar. uppercase M indicates the three abbreviations of the month.
Echo date ('N ').'
'; // 3,
Echo date ('F ').'
'; // March. all the English letters of the month

Echo '------
';

Echo date ('D ').'
'; // 09
Echo date ('J ').'
'; // 9
Echo date ('s ').'
'; // Th, indicating the suffix of the date.

Echo '------
';

Echo date ('g ').'
'; // 4, 12-hour format, with no 0 in front
Echo date ('g ').'
'; // 16, in 24-hour format, with leading 0
Echo date ('h ').'
'; // 16, 24 hour format, with no 0 in front
Echo date ('h ').'
'; // 01, in 12-hour format, with leading 0

Echo '------
';

Echo date ('I ').'
'; // 42, minutes

Echo '------
';

Echo date ('s ').'
'; // 26, seconds
Echo date ('s ').'
'; // Th, indicating the suffix of the date.

Echo '------
';

Echo date ('A ').'
'; // Pm, lowercase am (morning) pm (afternoon)
Echo date ('A ').'
'; // PM, uppercase

Echo '------
';

Echo date ('L ').'
'; // Thursday. the day is the day of the week in full (Tuesday)
Echo date ('L ').'
'; // 1. if it is a leap year, 1 is returned. otherwise, 0 is returned.
Echo date ('D ').'
'; // Thu, the abbreviation of the day of the week (Tue)


2. mktime ()

Mktime generates a timestamp for the specified time. prototype:

int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [,int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1]]]]]]] )

$ Tomorrow = mktime (0, 0, 0, date ("m"), date ("d") + 1, date ("Y "));
Echo "tomorrow is". date ("Y/m/d", $ tomorrow );

3. strtotime ()

$ D = strtotime ("pm else L 15 2015 ");
Echo "creation date is". date ("Y-m-d h: I: sa", $ d );

$ D = strtotime ("tomorrow ");
Echo date ("Y-m-d h: I: sa", $ d )."
";

$ D = strtotime ("next Saturday ");
Echo date ("Y-m-d h: I: sa", $ d )."
";

$ D = strtotime ("+ 3 Months ");
Echo date ("Y-m-d h: I: sa", $ d )."
";

Values 1, date string date (string $ format [, int $ timestamp]) echo date ('Y '). 'Br/'; // 2016 echo date ('Y '). 'Br/'; // 16 echo' ------ br/'; echo...

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.