Fechas en hora de Chile en Next.js
Tu servidor corre en UTC y tus usuarios están en Santiago. Con toLocaleString() el servidor y el navegador muestran horas distintas y React reclama un hydration mismatch. Las funciones de chile-kit/date siempre usan America/Santiago (con horario de verano) y arman el texto con tablas fijas, así que el HTML del servidor y el del navegador son idénticos.
Instalación: npm install chile-kit (o pnpm add, yarn add, bun add). Sin dependencias, con tipos, ESM; funciona en Node 22.12+, navegadores, Deno, Bun y Next.js.
import { chileToday, formatChileDate, formatChileDateTime, toChileISODate } from "chile-kit/date";
const at = "2026-12-05T02:30:00Z"; // 23:30 del 4 de diciembre en Santiago
formatChileDate(at); // "04-12-2026"
formatChileDate(at, "long"); // "4 de diciembre de 2026"
formatChileDateTime(at, "long"); // "4 de diciembre de 2026, 23:30"
toChileISODate(at); // "2026-12-04": el día en Chile, no en UTC
chileToday(); // hoy en Chile, corra donde corra el código
formatChileDate("2026-12-04"); // "04-12-2026": una fecha sola no se corre al día anterior
"use client";
// El mismo texto en el servidor UTC y en el navegador en Chile: sin hydration mismatch.
import { formatChileDateTime } from "chile-kit/date";
export function FechaPedido({ at }: { at: string }) {
return <time dateTime={at}>{formatChileDateTime(at, "long")}</time>;
}