-
-
Save DavidPeralvarez/443161e9c7bc43e156fb946f8756805d to your computer and use it in GitHub Desktop.
JavaScript - El objeto Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Curso de Javascript</title> | |
</head> | |
<body> | |
<script src="scripts.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Objetos Date */ | |
var fechaActual = new Date(); | |
console.log( fechaActual ); | |
// fecha en milisegundos | |
console.log( fechaActual.getTime() ); | |
// año | |
console.log( fechaActual.getFullYear() ); | |
// mes 0-11 | |
console.log( fechaActual.getMonth() ); | |
// día del mes | |
console.log( fechaActual.getDate() ); | |
// día de la semana 0 - 6 (domingo - sábado) | |
console.log( fechaActual.getDay() ); | |
// hora, minutos | |
console.log( fechaActual.getHours(), fechaActual.getMinutes(), fechaActual.getSeconds(), fechaActual.getMilliseconds() ); | |
var fechaMS = new Date( 1586858939315 ); | |
console.log( fechaMS ); | |
// year, month, day, hour, minutes, seconds, milliseconds | |
var fechaConcreta = new Date( 2060, 13, 25, 26, 30, 20, 60000 ); | |
console.log( fechaConcreta ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment