A RetroSearch Logo

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

Search Query:

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

Date.prototype.toJSON() - JavaScript | MDN

Date.prototype.toJSON()

Baseline Widely available

La méthode toJSON() renvoie une chaîne représentant l'objet Date sous forme JSON

Exemple interactif
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"
Syntaxe Valeur de retour

Une chaîne de caractères représentant la date indiquée.

Description

Les instances de Date identifient un instant précis dans le temps. Appeler toJSON() renvoie une chaîne de caractères formatée en JSON (en utilisant toISOString()), représentant la valeur de l'objet Date. Cette méthode est généralement utilisée, par défaut, pour sérialiser les objets Date lors d'une sérialisation au format JSON.

Exemple Utiliser toJSON()
var jsonDate = new Date().toJSON();
var retourVersDate = new Date(jsonDate);

console.log(jsonDate); //2015-10-26T07:46:36.611Z
Spécifications Compatibilité des navigateurs Voir aussi

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