react-usekit

Beta

formatDate

Format a date with locale support.

Installation

npx react-usekit@latest init

Select: utils → TypeScript or JavaScript → path -> formatDate

Usage

import { formatDate } from "./utils/formatDate";

function App() {
  const date = new Date();
  const formattedDate = formatDate(date, "en-US");

  return (
    <div>
      <p>Original: {date.toString()}</p>
      <p>Formatted: {formattedDate}</p>
    </div>
  );
}

API

Parameters

ParameterTypeDefaultDescription
dateDate-The date to format
localestring"en-US"The locale string

Returns

TypeDescription
stringThe formatted date string