revamp template
This commit is contained in:
36
src/utils/Date.ts
Normal file
36
src/utils/Date.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import moment from "moment";
|
||||
|
||||
const formatIsoDate = (isoDate: string) => {
|
||||
const date = new Date(isoDate);
|
||||
const monthNames = [
|
||||
'Jan',
|
||||
'Feb',
|
||||
'Mar',
|
||||
'Apr',
|
||||
'May',
|
||||
'Jun',
|
||||
'Jul',
|
||||
'Aug',
|
||||
'Sep',
|
||||
'Oct',
|
||||
'Nov',
|
||||
'Dec'
|
||||
];
|
||||
const day = date.getDate();
|
||||
const month = monthNames[date.getMonth()];
|
||||
const year = date.getFullYear();
|
||||
return `${day} ${month}, ${year}`;
|
||||
};
|
||||
|
||||
const get5LastYear = () => {
|
||||
const last5Years = [];
|
||||
for (let i = 0; i < 5; i++) {
|
||||
last5Years.push(moment().subtract(i, 'years').format('YYYY'));
|
||||
}
|
||||
|
||||
// console.log('last5Years :', last5Years);
|
||||
return last5Years;
|
||||
|
||||
};
|
||||
|
||||
export { formatIsoDate, get5LastYear };
|
||||
Reference in New Issue
Block a user