Skip to main content
Glama
useDate.ts1.04 kB
'use client'; import { date } from '@intlayer/core'; import { useContext } from 'react'; import { IntlayerClientContext } from '../IntlayerProvider'; /** * React client hook that provides a localized date/time formatter * bound to the current application locale. * * @returns {(date: Date | string | number, options?: DateProps) => string} * A function to format dates or timestamps into localized date/time strings. * * @example * ```tsx * const formatDate = useDate(); * * formatDate(new Date("2025-01-01")); * // "Jan 1, 2025" * * formatDate("2025-01-01T15:30:00Z", { * dateStyle: "full", * timeStyle: "short", * }); * // "Wednesday, January 1, 2025 at 3:30 PM" * * formatDate(1735689600000, { locale: "fr-FR", dateStyle: "long" }); * // "1 janvier 2025" * ``` * * @see createDate */ export const useDate = () => { const { locale } = useContext(IntlayerClientContext); return (...args: Parameters<typeof date>) => date(args[0], { ...args[1], locale: args[1]?.locale ?? locale, }); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server