JSFiddle - React, Tailwind, and code Playground

by borisjavier

JavaScript

var fechaHora = "23/06/2023 17:49"; // Fecha y hora en formato DD/MM/AAAA HH:MM
var partes = fechaHora.split(" "); // Dividir la cadena en fecha y hora
var fechaPartes = partes[0].split("/"); // Dividir la fecha en día, mes y año

// Crear un nuevo objeto Date con la fecha y hora especificadas
var fecha = new Date(fechaPartes[2], fechaPartes[1] - 1, fechaPartes[0], 0, 0, 0, 0);
var timestamp = fecha.getTime(); // Obtener el timestamp

console.log(timestamp); // El resultado será el timestamp correspondiente a la fecha 23/06/2023 a las 3:00 AM


const horaPartes = partes[1].split(':');
const fSHM = new Date(fechaPartes[2], fechaPartes[1] - 1, fechaPartes[0], horaPartes[0], horaPartes[1]);
                    const timestamp1 = fSHM.getTime();

                    console.log(timestamp1);