| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString | [Back] [Original] |
Get to know MDN better
Esta pgina ha sido traducida del ingls por la comunidad. Aprende ms y nete a la comunidad de MDN Web Docs.
This feature is well established and works across many devices and browser versions. Its been available across browsers since julio de 2015.
El mtodo toISOString() devuelve una cadena en el formato simplificado extendido ISO (ISO 8601), que siempre mide 24 o 27 caracteres de largo: (YYYY-MM-DDTHH:mm:ss.sssZ or YYYYYY-MM-DDTHH:mm:ss.sssZ, respectivamente). El uso horario no tiene retraso respecto a UTC, como lo denota el sufijo "Z".
dateObj.toISOString()
Una cadena que representa la fecha dada en el formato ISO 8601 segn la hora universal.
toISOString()var today = new Date("05 October 2011 14:48 UTC");
console.log(today.toISOString()); // Devuelve 2011-10-05T14:48:00.000Z
El ejemplo de arriba usa una cadena no estndar que podra no ser interpretada correctamente en navegadores distintos de Firefox.
Este mtodo fue estandarizado en ECMA-262 5 edicin. Los motores javascript que no han sido actualizados para soportar este mtodo pueden solucionar su ausencia de la siguiente manera:
if (!Date.prototype.toISOString) {
(function () {
function pad(number) {
if (number < 10) {
return "0" + number;
}
return number;
}
Date.prototype.toISOString = function () {
return (
this.getUTCFullYear() +
"-" +
pad(this.getUTCMonth() + 1) +
"-" +
pad(this.getUTCDate()) +
"T" +
pad(this.getUTCHours()) +
":" +
pad(this.getUTCMinutes()) +
":" +
pad(this.getUTCSeconds()) +
"." +
(this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
"Z"
);
};
})();
}
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-date.prototype.toisostring |
This page was last modified on 5 ago 2023 by MDN contributors.
DateDate.prototype.getDate()Date.prototype.getDay()Date.prototype.getFullYear()Date.prototype.getHours()Date.prototype.getMilliseconds()Date.prototype.getMinutes()Date.prototype.getMonth()Date.prototype.getSeconds()Date.prototype.getTime()getTimezoneOffset()getUTCDate()getUTCDay()Date.prototype.getUTCFullYear()getUTCHours()getUTCMilliseconds()getUTCMinutes()getUTCMonth()getUTCSeconds()getYear()setDate()Date.prototype.setFullYear()setHours()setMilliseconds()setMinutes()Date.prototype.setMonth()setSeconds()setTime()setUTCDate()setUTCFullYear()setUTCHours()setUTCMilliseconds()setUTCMinutes()setUTCMonth()setUTCSeconds()setYear()Date.prototype.toDateString()Date.prototype.toISOString()Date.prototype.toJSON()Date.prototype.toLocaleDateString()Date.prototype.toLocaleString()Date.prototype.toLocaleTimeString()toString()toTemporalInstant()toTimeString()Date.prototype.toUTCString()valueOf()[Symbol.toPrimitive]()Object/FunctionYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |