I have the following date string: 2022-03-21 00:00:00.0 CET
I tried this format: yyyy-MM-dd HH:mm:ss.S zzz
I got: RangeError: Invalid time value
You can use the library “date-fns-tz”.
Then you could do something like
import { utcToZonedTime } from 'date-fns-tz';
import { parse } from 'date-fns';
const currentFullDateTZ = '2022-03-21 00:00:00.0 CET';
const fullDate = currentDate.split('.')[0];
const format = 'yyyy-MM-dd HH:mm:ss';
const parsedDate = parse(currentFullDateTZ, format, new Date());
const timeZone = 'CET';
const zonedDate = utcToZonedTime(parsedDate, timeZone);
So basically you first split the date and the timezone and then format the date and apply the timezone.