I would like to restrict some actions if date is on sunday - e.g. do not allow create item on Sunday.
I use:
public isSunday(date: Date): boolean {
return date.getDay() === 0;
}
My problem is that my UTC offset is UTC+2.
Server and database runs on UTC TZ to prevent unwanted date and time shifts.
When I send datetime from frontend I use date.toISOString(), so my local datetime
2022-05-16 00:00:00 is converted to string 2022-05-15T22:00:00:000Z
When I check this date on the backend side, this date IS sunday, but in the UTC zone, not my local zone.
String value is converted to Date at the backend using following
new Date(input);
Edit: Value 2022-05-16T01:41:00+02:00 (sending value with utc offset info) does not work either