Skip to content

Instantly share code, notes, and snippets.

@hebertcisco
Created December 4, 2021 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hebertcisco/29e350901d8f0b4a2f6e63996a8443bf to your computer and use it in GitHub Desktop.
Save hebertcisco/29e350901d8f0b4a2f6e63996a8443bf to your computer and use it in GitHub Desktop.
Date Formatting Using Intl
import Intl from 'intl';
import 'intl/locale-data/jsonp/pt-BR';
export const dateFormat = (value: number | Date | undefined) => {
if (value) {
const date = new Date(value);
return Intl.DateTimeFormat('pt-BR', {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
hour12: false,
}).format(date);
}
return '';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment