mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2026-02-27 09:32:01 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -11,12 +11,12 @@ var birthday = new Date('1995-12-17T03:24:00');
|
||||
var birthday = new Date(1995, 11, 17);
|
||||
var birthday = new Date(1995, 11, 17, 3, 24, 0);
|
||||
|
||||
var unixTimestamp = Date.now(); // in milliseconds</code></pre>
|
||||
var unixTimestamp = Date.now(); // in milliseconds</code></code></pre>
|
||||
<h2 id=".E8.AF.AD.E6.B3.95" name=".E8.AF.AD.E6.B3.95">构造函数</h2>
|
||||
<pre class="brush: js">new Date();
|
||||
<pre><code class="language-javascript">new Date();
|
||||
new Date(<em>value</em>);
|
||||
new Date(<em>dateString</em>);
|
||||
new Date(<var>year</var>, <var>month</var>[, <var>day</var>[, <var>hour</var>[, <var>minutes</var>[, <var>seconds</var>[, <var>milliseconds</var>]]]]]);</pre>
|
||||
new Date(<var>year</var>, <var>month</var>[, <var>day</var>[, <var>hour</var>[, <var>minutes</var>[, <var>seconds</var>[, <var>milliseconds</var>]]]]]);</code></pre>
|
||||
<p></p><div class="blockIndicator note"><strong>Note:</strong> 需要注意的是只能通过调用 Date 构造函数来实例化日期对象:以常规函数调用它(即不加 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new">new</a> 操作符)将会返回一个字符串,而不是一个日期对象。另外,不像其他JavaScript 类型,<code style="font-style: normal;">Date 对象没有字面量格式。</code></div><p></p>
|
||||
<h3 id=".E5.8F.82.E6.95.B0" name=".E5.8F.82.E6.95.B0">参数</h3>
|
||||
<p></p><div class="blockIndicator note"><strong>Note:</strong> 当Date作为构造函数调用并传入多个参数时,如果数值大于合理范围时(如月份为13或者分钟数为70),相邻的数值会被调整。比如 new Date(2013, 13, 1)等于new Date(2014, 1, 1),它们都表示日期2014-02-01(注意月份是从0开始的)。其他数值也是类似,new Date(2013, 2, 1, 0, 70)等于new Date(2013, 2, 1, 1, 10),都表示时间2013-03-01T01:10:00。</div><p></p>
|
||||
@@ -187,12 +187,12 @@ new Date(<var>year</var>, <var>month</var>[, <var>day</var>[, <var>hour</var>[,
|
||||
<h2 id="Examples" name="Examples" style="margin-bottom: 20px; line-height: 30px;">例子</h2>
|
||||
<h3 id="Example:_Several_ways_to_assign_dates" name="Example:_Several_ways_to_assign_dates" style="line-height: 24px;">例子:创建一个日期对象的几种方法</h3>
|
||||
<p>下例展示了用来创建一个日期对象的多种方法。</p>
|
||||
<pre class="brush: js">var today = new Date();
|
||||
<pre><code class="language-javascript">var today = new Date();
|
||||
<code>var today = new Date(1453094034000);// by timestamp(accurate to the millimeter)</code>
|
||||
var birthday = new Date("December 17, 1995 03:24:00");
|
||||
var birthday = new Date("1995-12-17T03:24:00");
|
||||
var birthday = new Date(1995,11,17);
|
||||
var birthday = new Date(1995,11,17,3,24,0);</pre>
|
||||
var birthday = new Date(1995,11,17,3,24,0);</code></pre>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 0px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 19px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 38px; background: 0px 0px;"> </div>
|
||||
@@ -200,12 +200,12 @@ var birthday = new Date(1995,11,17,3,24,0);</pre>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 76px; background: 0px 0px;"> </div>
|
||||
<h3 id="例子:两位数年份表示_1900_-_1999_年">例子:两位数年份表示 1900 - 1999 年</h3>
|
||||
<p>为了能够创建和获取 0 到 99 之间的年份,应该使用 <a href="Reference/Global_Objects/Date/setFullYear" title="setFullYear() 方法根据本地时间为一个日期对象设置年份。"><code>Date.prototype.setFullYear()</code></a> 和 <a href="Reference/Global_Objects/Date/getFullYear" title="getFullYear() 方法根据本地时间返回指定日期的年份。"><code>Date.prototype.getFullYear()</code></a> 方法。</p>
|
||||
<pre class="brush: js">var date = new Date(98, 1); // Sun Feb 01 1998 00:00:00 GMT+0000 (GMT)
|
||||
<pre><code class="language-javascript">var date = new Date(98, 1); // Sun Feb 01 1998 00:00:00 GMT+0000 (GMT)
|
||||
|
||||
// 弃用的方法, 98在这里被映射为1998
|
||||
date.setYear(98); // Sun Feb 01 1998 00:00:00 GMT+0000 (GMT)
|
||||
|
||||
date.setFullYear(98); // Sat Feb 01 0098 00:00:00 GMT+0000 (BST)</pre>
|
||||
date.setFullYear(98); // Sat Feb 01 0098 00:00:00 GMT+0000 (BST)</code></pre>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 0px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 19px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 38px; background: 0px 0px;"> </div>
|
||||
@@ -214,27 +214,27 @@ date.setFullYear(98); // Sat Feb 01 0098 00:00:00 GMT+0000 (BST)</pr
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 95px; background: 0px 0px;"> </div>
|
||||
<h3 id="Example:_Calculating_elapsed_time" name="Example:_Calculating_elapsed_time" style="line-height: 24px;">例子:计算经过的时间</h3>
|
||||
<p>下例展示了如何计算两个日期对象的时间差:</p>
|
||||
<pre class="brush: js">// 使用 Date 对象
|
||||
<pre><code class="language-javascript">// 使用 Date 对象
|
||||
var start = Date.now();
|
||||
|
||||
// 这里进行耗时的方法调用:
|
||||
doSomethingForALongTime();
|
||||
var end = Date.now();
|
||||
var elapsed = end - start; // 运行时间的毫秒值</pre>
|
||||
<pre class="brush: js">// 使用内建的创建方法
|
||||
var elapsed = end - start; // 运行时间的毫秒值</code></pre>
|
||||
<pre><code class="language-javascript">// 使用内建的创建方法
|
||||
var start = new Date();
|
||||
|
||||
// 这里进行耗时的方法调用:
|
||||
doSomethingForALongTime();
|
||||
var end = new Date();
|
||||
var elapsed = end.getTime() - start.getTime(); // 运行时间的毫秒值</pre>
|
||||
var elapsed = end.getTime() - start.getTime(); // 运行时间的毫秒值</code></pre>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 0px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 19px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 38px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 57px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 76px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 95px; background: 0px 0px;"> </div>
|
||||
<pre class="brush: js" dir="ltr">// to test a function and get back its return
|
||||
<pre><code class="language-js" dir="ltr">// to test a function and get back its return
|
||||
function printElapsedTime (fTest) {
|
||||
var nStartTime = Date.now(),
|
||||
vReturn = fTest(),
|
||||
@@ -243,7 +243,7 @@ function printElapsedTime (fTest) {
|
||||
return vReturn;
|
||||
}
|
||||
yourFunctionReturn = printElapsedTime(yourFunction);
|
||||
</pre>
|
||||
</code></pre>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 0px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 19px; background: 0px 0px;"> </div>
|
||||
<div class="line-number" style="margin-top: 1em; position: absolute; left: 0px; right: 0px; line-height: inherit; top: 38px; background: 0px 0px;"> </div>
|
||||
|
||||
Reference in New Issue
Block a user