-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfechas.js
More file actions
48 lines (28 loc) · 801 Bytes
/
fechas.js
File metadata and controls
48 lines (28 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// obtener fecha construida
const nacimiento = new Date(1987, 7, 12)
// fecha de hoy
const hoy = new Date()
// tiempo, restar hoy menos fecha de nacimiento
// nos regresa el tiemp en milisegundos
const tiempo = hoy - nacimiento
// tiempo en segundos:, en cada segundo existen 1000 milisegundos.
const tiempoSegundos = tiempo / 1000
// tiempo en minutos
// en 1 minuto existen 60 segundos
const tiempoMin = tiempoSegundos / 60
// tiempo en horas
const tiempoHoras = tiempoMin / 60
// proximo cumpleaños
const proximoCumpleanos = new Date(hoy.getFullYear(), nacimiento.getMonth(), nacimiento.getDate())
proximoCumpleanos
const diasSemana = [
"Domingo",
"Lunes",
"Martes",
"Miercoles",
"Jueves",
"Viernes",
"Sabado"
]
// Mostrar
console.log(diasSemana[proximoCumpleanos.getDay()])