calendar done
This commit is contained in:
@@ -28,18 +28,37 @@ const monthsAbr = [
|
||||
"Dic"
|
||||
];
|
||||
|
||||
export const getDayMonthYear = (value) => {
|
||||
if(value === null) return 'Fecha invalida';
|
||||
const year = value.substring(0, 4);
|
||||
const month = value.substring(5, 7);
|
||||
const day = value.substring(8, 10);
|
||||
return `${day}/${month}/${year}`;
|
||||
};
|
||||
|
||||
export const getDateMonthDay = (value) => {
|
||||
const date = new Date(value)
|
||||
return date.toLocaleString(['en-US'], {
|
||||
|
||||
console.log(value)
|
||||
// Crear una fecha a partir del valor proporcionado
|
||||
const date = new Date(value);
|
||||
// Ajustar la fecha a la zona horaria de México manualmente
|
||||
const utcOffset = -6; // Offset de UTC para la hora estándar de México
|
||||
date.setHours(date.getHours() + utcOffset);
|
||||
// Convertir la fecha a la hora de México
|
||||
const options = {
|
||||
timeZone: 'America/Mexico_City',
|
||||
month: 'short',
|
||||
day: '2-digit',
|
||||
year: 'numeric',
|
||||
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// Convertir la fecha a una cadena localizada con la zona horaria de México
|
||||
const dateString = date.toLocaleString('es-ES', options);
|
||||
|
||||
return dateString;
|
||||
};
|
||||
|
||||
export const getDateMonthDayEs = (value, isFull = false) => {
|
||||
console.log(value);
|
||||
const date = new Date(value)
|
||||
let month = '';
|
||||
if(isFull) {
|
||||
@@ -66,4 +85,11 @@ export const getDateTime = (value, hour) => {
|
||||
const dateFormat = `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
export const formatOnlyDate = (date) => {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0'); // Agregar cero si es necesario
|
||||
const day = String(date.getDate()).padStart(2, '0'); // Agregar cero si es necesario
|
||||
return `${year}/${month}/${day}`;
|
||||
}
|
||||
Reference in New Issue
Block a user