Introduction
This article introduces the use of Date in PHP and JS.
Detailed introduction
The difficulty encountered today is Date outputting the time in 24-hour format. Regarding this weak link, make a simple note.
PHP Date()
php date() Method to output 24-hour time: echo date("Y-m-d H:i:s");
Method to output 12-hour time: echo date("y-m-d h:i:s");
The main difference between uppercase and lowercase is completeness, for example, H
and h
- corresponding to the 24/12 hour clock.
The following code:
<code><span>echo</span> date(<span>"Y-m-d H:i:s"</span>).<span>"<br />"</span>; <span>echo</span> date(<span>"y-m-d h:i:s"</span>);</code>
The output to the browser is:
<code>2014<span>-03-01</span> 14<span>:09</span><span>:15</span> 14<span>-03-01</span> 02<span>:09</span><span>:15</span></code>
JS Date()
JS object used to process time, including various methods of processing time, simple and easy to implement.
Code block of commonly used methods:
<code><span>//①:</span> document.write(<span>Date</span>()) <span>var</span> d=<span>new</span><span>Date</span>() <span>var</span> day=d.getDate() <span>var</span> m + <span>1</span><span>//注:该方法返回0~11</span><span>var</span> year=d.getFullYear() <span>//②</span> document.write(year + <span>"/"</span> + month + <span>"/"</span> + day)</code>
Corresponding output result block (please check the corresponding line number for easier reading):
<code>①:Fri May 13 2016 18:55:34 GMT+0800 (中国标准时间) ②:2016/4/13</code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });References
php date() method to output 24-hour or 12-hour format
JavaScript Date object - W3C
The above has introduced the basic level - Date of PHP && JS, including date and php content. I hope it will be helpful to friends who are interested in PHP tutorials.