A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON below:

Date.prototype.toJSON() - JavaScript | MDN

Date.prototype.toJSON()

Baseline Widely available

El metodo toJSON() retorna una representacion de cadena del objeto Date

Pruébalo
const event = new Date("August 19, 1975 23:15:30 UTC");

const jsonDate = event.toJSON();

console.log(jsonDate);
// Expected output: "1975-08-19T23:15:30.000Z"

console.log(new Date(jsonDate).toUTCString());
// Expected output: "Tue, 19 Aug 1975 23:15:30 GMT"
Syntaxis Valor retornado

Una representación de cadena de la fecha dada.

Descripción

Date las instancias se refieren a un momento específico en el tiempo. Llamando a toJSON() retorna un string (usando toISOString()) representando el Date valor del objeto. Este método generalmente está destinado, de forma predeterminada, a serializar de manera útil Date objetos durante la serialización JSON .

Ejemplos Usando toJSON()
var jsonDate = new Date().toJSON();
var backToDate = new Date(jsonDate);

console.log(jsonDate); //2015-10-26T07:46:36.611Z
Especificaciones Compatibilidad con navegadores Ver también

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4