fix: date local

This commit is contained in:
Alexandro Uc Santos
2025-07-30 21:33:21 -06:00
parent dcf963d5f9
commit 9ed4035467
6 changed files with 40 additions and 25 deletions

View File

@@ -101,6 +101,29 @@ export const getDateOnly = (value) => {
return dateFormat;
}
export const getDateToLocal = (value) => {
if (!value) return 'Fecha inválida';
const date = new Date(value);
return date.toLocaleDateString('es-MX', {
timeZone: 'America/Mexico_City',
day: '2-digit',
month: '2-digit',
year: 'numeric'
});
};
export const getDateTimeFormat = (value, hour) => {
const year = value.substring(0, 4);
const month = value.substring(5, 7);
const day = value.substring(8, 10);
// Crear la cadena de fecha formateada
const dateFormat = `${year}-${month}-${day} 0${hour}:00`;
return dateFormat;
}
export const formatOnlyDate = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // Agregar cero si es necesario