aboutsummaryrefslogtreecommitdiff
path: root/src/components/DateString/DateString.tsx
blob: e31b52e010fe2d35d20e7e6e1a471d80450a8555 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import React from 'react';

interface PropTypes {
  value: Date | string;
}

const DATE_FORMAT = {
  month: 'long',
  day: 'numeric',
  year: 'numeric',
  hour: '2-digit',
  minute: '2-digit'
};

const DateString: React.FC<PropTypes> = ({ value }) => {
  const date = new Date(value);
  const formatted = date.toLocaleString('default', DATE_FORMAT);

  return <>{formatted}</>;
};

export default DateString;