Home  >  Article  >  php教程  >  PHP time formatting

PHP time formatting

WBOY
WBOYOriginal
2016-12-01 00:00:231580browse

Common time formatting usage
// Set the default time zone to be used. Available since PHP 5.1 <br> date_default_timezone_set('UTC');<br> <br> // Output is similar to: Saturday<br> echo date("l");<br> <br> // Output is similar: Saturday 26th of November 2016 10:12:46 PM<br> echo date('l dS of F Y h:i:s A');<br> <br> // Output: November 26, 2016 is on a Saturday<br> echo "November 26, 2016 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2016));<br> <br> /* Use constants in format parameters */<br> // Output is similar: Mon, 15 Aug 26 10:20:16 +0800<br> echo date(DATE_RFC822);<br> <br> // Output is similar: 2016-11-26T00:00:00+00:00<br> echo date(DATE_ATOM, mktime(0, 0, 0,11,26, 2016));<br> <br> //Print out the current date<br> echo date('Y year m month d day');<br> <br> //Formatting time has passed<br> echo date('Y year m month d day', strtotime('2016-11-26'));

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Sign-in implementationNext article:Sign-in implementation