mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2026-02-28 01:58:28 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/intl-datetimeformat.html" width="100%"></iframe></div>
|
||||
<p class="hidden">交互示例的源代码存储在 GitHub 资源库。如果你愿意分布交互示例,请复制<a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a>,并向我们发送一个pull请求。</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code>new Intl.DateTimeFormat([<var>locales</var>[, <var>options</var>]])
|
||||
Intl.DateTimeFormat.call(<var>this</var>[, <var>locales</var>[, <var>options</var>]])</code></pre>
|
||||
<pre><code class="language-javascript"><code>new Intl.DateTimeFormat([<var>locales</var>[, <var>options</var>]])
|
||||
Intl.DateTimeFormat.call(<var>this</var>[, <var>locales</var>[, <var>options</var>]])</code></code></pre>
|
||||
<h3 id="参数">参数</h3>
|
||||
<dl>
|
||||
<dt><code>locales</code></dt>
|
||||
@@ -101,15 +101,15 @@ Intl.DateTimeFormat.call(<var>this</var>[, <var>locales</var>[, <var>options</va
|
||||
<h2 id="实例">实例</h2>
|
||||
<h3 id="使用_DateTimeFormat">使用 <code>DateTimeFormat</code></h3>
|
||||
<p>不指定locale时,DateTimeFormat使用默认的locale 和 默认的 options</p>
|
||||
<pre class="brush: js">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
|
||||
<pre><code class="language-javascript">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
|
||||
|
||||
//参数未填时使用默认的locale和默认的时区
|
||||
console.log(new Intl.DateTimeFormat().format(date));
|
||||
//如果是在洛杉矶那么值为 → "12/19/2012"
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h3 id="使用locales">使用<code>locales</code></h3>
|
||||
<p>这个例子显示了本地化日期和时间格式的一些变化。为了获得用于您的应用程序的用户界面的语言格式,请确保使用locales参数确保指定语言(可能还有一些回退语言):</p>
|
||||
<pre class="brush: js">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
|
||||
<pre><code class="language-javascript">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
|
||||
|
||||
// 下面是假定的所在时区
|
||||
// 洛杉矶(America/Los_Angeles for the US)
|
||||
@@ -139,10 +139,10 @@ console.log(new Intl.DateTimeFormat('ja-JP-u-ca-japanese').format(date));
|
||||
//那么将使用印尼语(id)
|
||||
console.log(new Intl.DateTimeFormat(['ban', 'id']).format(date));
|
||||
// → "20/12/2012"
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h3 id="使用options">使用<code>options</code></h3>
|
||||
<p>可以使用 <code>options </code>参数来自定义 <font face="Consolas, Liberation Mono, Courier, monospace">日期时间格式化</font>方法返回的字符串。</p>
|
||||
<pre class="brush: js">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
|
||||
<pre><code class="language-javascript">var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
|
||||
|
||||
//请求参数(options)中包含参数星期(weekday),并且该参数的值为长类型(long)
|
||||
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
|
||||
@@ -171,7 +171,7 @@ options = {
|
||||
};
|
||||
console.log(date.toLocaleString('en-US', options));
|
||||
// → "12/19/2012, 19:00:00"
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user