PHP date and time, PHP Date and Time
1. date
string date ( string $format [, int $timestamp ] )
Echo date ('y'). '<br/>'; // 2016
Echo date ('y'). '<br/>'; // 16
Echo '------ <br/> ';
Echo date ('M'). '<br/>'; // 03
Echo date ('M'). '<br/>'; // Mar. uppercase M indicates the three abbreviated characters of the month.
Echo date ('n'). '<br/>'; // 3,
Echo date ('F'). '<br/>'; // March, which indicates all the English letters of the month.
Echo '------ <br/> ';
Echo date ('D'). '<br/>'; // 09
Echo date ('J'). '<br/>'; // 9
Echo date ('s'). '<br/>'; // th, indicating the date suffix.
Echo '------ <br/> ';
Echo date ('G'). '<br/>'; // 4, in 12-hour format, without 0
Echo date ('G'). '<br/>'; // 16, in 24-hour format, with leading 0
Echo date ('H'). '<br/>'; // 16,24 hour system, with no 0 in front
Echo date ('H'). '<br/>'; // 01, in 12-hour format, with leading 0
Echo '------ <br/> ';
Echo date ('I'). '<br/>'; // 42, minutes
Echo '------ <br/> ';
Echo date ('s'). '<br/>'; // 26, seconds
Echo date ('s'). '<br/>'; // th, indicating the date suffix.
Echo '------ <br/> ';
Echo date ('A'). '<br/>'; // pm, lowercase am (morning) pm (afternoon)
Echo date ('A'). '<br/>'; // PM, uppercase
Echo '------ <br/> ';
Echo date ('l'). '<br/>'; // Thursday, which is the day of the week in full (Tuesday)
Echo date ('l'). '<br/>'; // 1. 1 is returned for a leap year. Otherwise, 0 is returned.
Echo date ('D'). '<br/>'; // Thu, which is the abbreviation of the three characters 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). "<br> ";
$ D = strtotime ("next Saturday ");
Echo date ("Y-m-d h: I: sa", $ d). "<br> ";
$ D = strtotime ("+ 3 Months ");
Echo date ("Y-m-d h: I: sa", $ d). "<br> ";