Get day from day/month from index.
import { indexToDay, indexToMonth } from '@sgx4u/date-time-utils';
const Demo = () => {
const dayName = indexToDay(0);
const monthName = indexToMonth(0);
return (
<p>
Day: {dayName} | Month: {monthName}
</p>
);
};
indexToDay(index, format): string;
indexToMonth(index, format): string;
index
The index of day/month,type
: numberformat
Use short/long name,type
: 'short' | 'long',default
- long,optional
indexToDay
- index: 0,result
: Sunday, ShortName: SunindexToMonth
- index: 0,result
: January, ShortName: Jan
indexToDay
index range is 0-6, any value outside the range will showInvalid Index
indexToMonth
index range is 0-11, any value outside the range will showInvalid Index