PHP Date and time

Source: Internet
Author: User
Tags echo date

1. Date

string Date string $format $timestamp ] )

echo Date (' Y '). ' <br/> ';//2016
echo date (' Y '). ' <br/> ';//16

Echo '------<br/> ';

echo date (' m '). ' <br/> ';//03
echo Date (' M '). ' <br/> ';//Mar, Capital M denotes 3 abbreviated characters of the month
echo Date (' n '). ' <br/> ';//3,
echo Date (' F '). ' <br/> ';//March, full written in English month

Echo '------<br/> ';

echo Date (' d '). ' <br/> ';//09
echo Date (' J '). ' <br/> ';//9
echo Date (' S '). ' <br/> ';//th, which represents the suffix of the date.

Echo '------<br/> ';

echo Date (' G '). ' <br/> ';//4, 12-hour system, front without 0
echo Date (' G '). ' <br/> ';//16, 24-hour with leading 0
echo Date (' H '). ' <br/> ';//16, 24-hour system, front without 0
echo Date (' H '). ' <br/> ';//01, 12-hour with leading 0

Echo '------<br/> ';

echo Date (' I '). ' <br/> ';//42, Min

Echo '------<br/> ';

echo Date (' s '). ' <br/> ';//26, Sec
echo Date (' S '). ' <br/> ';//th, which represents the suffix of the date.

Echo '------<br/> ';

echo Date (' a '). ' <br/> ';//PM, lowercase am (a.m.) PM (PM)
echo Date (' A '). ' <br/> ';//PM, uppercase

Echo '------<br/> ';

echo Date (' L '). ' <br/> ';//Thursday, day of the week is written in English full (Tuesday)
echo Date (' L '). ' <br/> ';//1, Leap year returns 1 otherwise 0
echo Date (' D '). ' <br/> ';//Thu, which represents the 3-character abbreviation for 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 ("10:38pm April 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>";

?

PHP Date and time

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.