Basic Level - Date of PHP && JS

WBOY
Release: 2016-07-29 08:49:21
Original
964 people have browsed it

  • Introduction
  • Detailed introduction
    • PHP Date
    • JS Date

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>
Copy after login

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>
Copy after login

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>
Copy after login

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>
Copy after login

References
php date() method to output 24-hour or 12-hour format
JavaScript Date object - W3C

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template