getDayOfWeek()
getDayOfWeek(
date
):string
Defined in: src/utils/dateUtils.ts:104
Gets the day of the week for a given date.
Parameters
date
The date (or string) for which to get the day of the week.
string
| Date
Returns
string
The name of the day of the week (e.g., 'Monday', 'Tuesday'). Returns an empty string if the input is invalid.
Example
tsx
const day1 = getDayOfWeek(new Date('2024-11-19')); // 'Tuesday'
const day2 = getDayOfWeek('2024-11-19'); // 'Tuesday'
const day3 = getDayOfWeek('Invalid date string'); // ''