• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

259
Views
Passing my payload through JSON.parse alters my date object values to not line up

Prior to using JSON.parse(), my payload contents are as follows:

let payload = {
     "name":"bob",
     "timeDetails":
        [
            {
                "windowName":"Window A",
                "windowTimes":
                    {
                        "startDate":"2021-11-20T20:39:46.785Z",
                        "endDate":"2021-11-20T20:39:54.786Z"
                    }
            }
        ]
    }

So paying particular attention to my dates, when I then proceed to issue the following on the above payload, i.e.:

let job = JSON.parse(payload);
console.log(job);

I am now getting the following startDate and endDate returned which is not the same as my original payload dates, i.e. from my console log:

startDate: Sun Nov 21 2021 16:00:00 GMT+1100 (Australian Eastern Daylight Time) {}
endDate: Sun Nov 21 2021 23:00:00 GMT+1100 (Australian Eastern Daylight Time) {}

I am not so much concerned about the time portion but I would've thought I would've seen the dates as: Sat Nov 20 2021 for both startDate/endDate?

Can someone help with what I am missing as need to ensure that dates are like for like.

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Taking date string as UTC Time zone ("2021-11-20T20:39:46.785Z", UTC format). It adds 11 (GMT+1100 (Australian Eastern Daylight Time) hours to UTC time, so adding 11 hours to Nov 20 gets Nov 21 as a result If you want to get the Exact UTC zone we have to convert it to UTC format

almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error