Get the current Unix timestamp
from 1970.1.1 (00:00:00) - the number of seconds of the current time and
get the current date
date();
date(timestamp format, Specify timestamp [default is the current date and time, optional])
<code><span>//date函数,第二个参数取默认值的情况</span><span>echo</span> date(<span>"Y-m-d"</span>);<span>//2014-03-30</span><span>//date函数,第二个参数有值的情况</span><span>echo</span> date(<span>"Y-m-d"</span>,<span>'1396193923'</span>);<span>//2014-03-30,1396193923表示2014-03-30的unix时间戳</span></code>
Get the timestamp of the date
strtotime();
<code><span>strtotime(<span>"2016-02-05"</span>)</span>; <span>strtotime(<span>"2016-2-5"</span>)</span>; <span>//测试也可行</span></code>
Convert the formatted date string into Unix timestamp
<code><span>strtotime(<span>"now"</span>)</span>; <span>strtotime(<span>"+1 seconds"</span>)</span>; <span>strtotime(<span>"+1 day"</span>)</span>; <span>strtotime(<span>"+1 week"</span>)</span>; <span>strtotime(<span>"+1 week 3 days 7 hours 5 seconds"</span>)</span>; </code>
format Greenwich Mean Time (GMT)
<code><span>// gmdate() </span><span>//Y-m-d H:i:s</span><span>date_default_timezone_set(<span>"Asia/Shanghai"</span>)</span>; echo <span>date(<span>'Y-m-d H:i:s'</span>, <span>time()</span>)</span>; echo <span>gmdate(<span>'Y-m-d H:i:s'</span>, <span>time()</span>)</span>;</code>
The above has introduced PHP---Date and Time, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.