Is there a way to display a formatted date from NextUI's DatePicker and DateInput?
Asked Answered
V

1

7

I'm using the NextUI library version 2.3.6. I'd like to use the DatePicker or the DateInput.

However, the default format displayed is mm/dd/yyyy; I need to display the date in the following format: dd/mm/yyyy.

Is there any way of using a format other than the default within a DatePicker or a DateInput?

Verbal answered 2/5 at 8:55 Comment(0)
V
10

I asked the question on the official NextUI Discord and they gave me the solution!

All you have to do is change the locale on the NextUIProvider, for example :

"use client";

import {type ReactNode} from "react";
import {NextUIProvider} from "@nextui-org/react";

export function AppProvider(props: AppProviderProps) {
  const {children, className} = props;

  return (
    <NextUIProvider locale="fr-FR" className={className}>
      {children}
    </NextUIProvider>
  );
}

interface AppProviderProps {
  children: ReactNode;
  className?: string;
}
Verbal answered 2/5 at 10:21 Comment(1)
Fantastic! I solved my problem. ThanksTrichoid

© 2022 - 2024 — McMap. All rights reserved.