mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 17:21:41 +10:00
wip: refresh design
This commit is contained in:
21
apps/web/src/components/formatter/locale-date.tsx
Normal file
21
apps/web/src/components/formatter/locale-date.tsx
Normal file
@ -0,0 +1,21 @@
|
||||
'use client';
|
||||
|
||||
import { HTMLAttributes, useEffect, useState } from 'react';
|
||||
|
||||
export type LocaleDateProps = HTMLAttributes<HTMLSpanElement> & {
|
||||
date: string | number | Date;
|
||||
};
|
||||
|
||||
export const LocaleDate = ({ className, date, ...props }: LocaleDateProps) => {
|
||||
const [localeDate, setLocaleDate] = useState(() => new Date(date).toISOString());
|
||||
|
||||
useEffect(() => {
|
||||
setLocaleDate(new Date(date).toLocaleString());
|
||||
}, [date]);
|
||||
|
||||
return (
|
||||
<span className={className} {...props}>
|
||||
{localeDate}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user