Skip to content

Commit

Permalink
add case where fromatDate receives number
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmanos committed Nov 29, 2024
1 parent 3f53110 commit 5c055f3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/functions/DateFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ export function formatDate(value, format = 'datetime') {
const simpleDateRegex = /^\d{4}-\d{2}-\d{2}$/;

let date;
if (iso8601Regex.test(value)) {
if (typeof value == 'number') {
return new Date(value * 1000).toLocaleDateString('en-GB');
}
else if (iso8601Regex.test(value)) {
date = new Date(value);
} else if (simpleDateRegex.test(value)) {
date = new Date(value);
Expand Down

0 comments on commit 5c055f3

Please sign in to comment.