Date.prototype.getSeconds()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
El método getSeconds()
devuelve los segundos en la fecha especificada de acuerdo a la hora local.
Pruébalo
const moonLanding = new Date("July 20, 69 00:20:18");
console.log(moonLanding.getSeconds());
// Expected output: 18
Sintaxis
dateObj.getSeconds()
Valor devuelto
Un número entero, entro 0 y 59, representando los segundos en la fecha dada de acuerdo a la hora local.
Ejemplos
Utilizando getSeconds()
La segunda sentencia asigna el valor 30 a la variable seconds
, en base al valor del objeto Date
Xmas95
.
js
var Xmas95 = new Date("December 25, 1995 23:15:30");
var seconds = Xmas95.getSeconds();
console.log(seconds); // 30
Especificaciones
Specification |
---|
ECMAScript® 2025 Language Specification # sec-date.prototype.getseconds |
Compatibilidad con navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getSeconds |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.