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
Parameter | Type | Default | Description |
---|---|---|---|
date | Date | - | The date to format |
locale | string | "en-US" | The locale string |
Returns
Type | Description |
---|---|
string | The formatted date string |