diff options
Diffstat (limited to 'files/pt-br/web/javascript/reference/global_objects/date/now/index.html')
| -rw-r--r-- | files/pt-br/web/javascript/reference/global_objects/date/now/index.html | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/files/pt-br/web/javascript/reference/global_objects/date/now/index.html b/files/pt-br/web/javascript/reference/global_objects/date/now/index.html new file mode 100644 index 0000000000..2eef32c0b7 --- /dev/null +++ b/files/pt-br/web/javascript/reference/global_objects/date/now/index.html @@ -0,0 +1,126 @@ +--- +title: Date.now() +slug: Web/JavaScript/Reference/Global_Objects/Date/now +tags: + - JavaScript + - Reference + - Referencia + - data + - metodo + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/Date/now +--- +<div>{{JSRef("Global_Objects", "Date")}}</div> + +<h2 id="Summary" name="Summary">Resumo</h2> + +<p>O método<strong><code> Date.now()</code></strong> retorna o número de milisegundos decorridos desde 1 de janeiro de 1970 00:00:00 UTC.</p> + +<h2 id="Syntax" name="Syntax">Sintaxe</h2> + +<pre class="syntaxbox">var timeInMs = Date.now(); +</pre> + +<h3 id="Parameters" name="Parameters">Parâmetros</h3> + +<p>Nenhum.</p> + +<h2 id="Description" name="Description">Descrição</h2> + +<p>O método <strong><code>now()</code></strong> retorna os milisegundos decorridos desde 1 de janeiro de 1970 00:00:00 UTC até agora como um {{jsxref("Global_Objects/Number", "Number")}}.</p> + +<p>Por que <strong><code>now</code> </strong>é um método estático de <strong><code>Date</code></strong>, você sempre o usará como <strong><code>Date.now()</code></strong>.</p> + +<h2 id="Compatibility" name="Compatibility">Polyfill</h2> + +<p>Este método foi padronizado no ECMA-262 5<sup>th</sup> edition. Em ambientes que não estão atualizados para suportar este método você pode suprir esta carência utilizando o seguinte:</p> + +<pre class="brush: js">if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; +} +</pre> + +<h2 id="Especificações">Especificações</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificação</th> + <th scope="col">Status</th> + <th scope="col">Comentário</th> + </tr> + <tr> + <td>{{SpecName('ES5.1', '#sec-15.9.4.4', 'Date.now')}}</td> + <td>{{Spec2('ES5.1')}}</td> + <td>Definição inicial. Implementado no JavaScript 1.5</td> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-date.now', 'Date.now')}}</td> + <td>{{Spec2('ES6')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidade_de_Browser">Compatibilidade de Browser</h2> + +<p>Baseado em <a href="http://kangax.github.com/es5-compat-table/">Kangax's compat table</a>.</p> + +<p>{{ CompatibilityTable() }}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Suporte básico</td> + <td>5</td> + <td>3</td> + <td>9</td> + <td>10.50</td> + <td>4</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Chrome for Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>suporte básico</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Veja_também">Veja também</h2> + +<ul> + <li>{{domxref("window.performance.now")}} - fornece timestamps com sub-millisegundo precisão para uso em medir o desempenho da página</li> + <li>{{domxref("console.time")}} / {{domxref("console.timeEnd")}}</li> +</ul> |
