-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclase38plus.html
More file actions
23 lines (21 loc) · 815 Bytes
/
clase38plus.html
File metadata and controls
23 lines (21 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
function diasEntreFechas(fecha1, fecha2) {
const unDia = 1000 * 60 * 60 * 24
const diferencia = Math.abs(fecha1 - fecha2)
return Math.floor(diferencia / unDia)
}
const hoy = new Date()
const nacimiento = new Date(1997, 0, 21)
//Con variables de tipo Date, se pueden realizar operaciones de suma y resta similares a las que se realizan con números.
//El resultado que se obtiene está en milisegundos, por lo que luego hay que hacer algunas operaciones adicionales para llevarlos a días,
//meses o años según queramos. También aplica para Horas, Minutos, Segundos y Milisegundos.
</script>
</body>
</html>