Home >Backend Development >PHP Tutorial >Explain the related applications of PHP function Date()_PHP tutorial

Explain the related applications of PHP function Date()_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-15 13:28:58919browse

If we want to write 1. PHP function Date() to get the current time

Code:

<ol class="dp-xml"><li class="alt">
<span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> echo $</SPAN><SPAN class=attribute><FONT color=#ff0000>showtime</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>date</FONT></SPAN><SPAN>("Y-m-d H:i:s");</SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span> </span>
</li></ol>

Display format: year-month-day hour: minute: second

2. Solution to the problem of obtaining time difference of 8 hours with PHP function Date() in PHP5

Just add a definition before the output time: date_default_timezone_set("PRC");, code:

<ol class="dp-xml"><li class="alt">
<span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN>   </SPAN></SPAN><LI class=""><SPAN>date_default_timezone_set("PRC");   </SPAN><LI class=alt><SPAN>echo date("Y-m-d H:i:s");   </SPAN><LI class=""><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span>  </span>
</li></ol>

The above is the relevant knowledge we have introduced about the PHP function Date() , hope it helps everyone.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446403.htmlTechArticleWe want to write 1. PHP function Date() to get the current time code: ? php echo$ showtime = date ("Y-m-dH:i:s"); ? Display format: year-month-day hour: minute: second, PH in PHP5...
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