Unable to convert local timezone to UTC timezone

Viewed 25

I'm attempting to make a calendar on the front end using Fullcalendar. Once a date is clicked it is meant to send a request to the server to see all the available slots for that day. However before the request is sent I want it to convert the users timezone to UTC then send the request and then server side I'll double check if the request was still made in UTC time. When I attempt to convert the date it doesn't change it just shows same timezone. I'm also using Date-FNS.

After reading some suggestions it said to parse the date before converting it to the UTC timezone so thats what I did.

        async handleDateClick(arg)
        {
            console.log(arg.date)
            const parseDate = parseJSON(arg.date)
            const convertToUTCDate = zonedTimeToUtc(parseDate)
            console.log(convertToUTCDate)
        },

Before


        async handleDateClick(arg)
        {
            console.log(arg.date)
            const convertToUTCDate = zonedTimeToUtc(arg.date)
            console.log(convertToUTCDate)
        },

Both console logs report this time... which is GMT+1

Mon Sep 05 2022 00:00:00 GMT+0100 (British Summer Time)
Mon Sep 05 2022 00:00:00 GMT+0100 (British Summer Time)

0 Answers
Related