Skip to main content
edited for readability
Source Link
the Tin Man
  • 160.9k
  • 44
  • 222
  • 308

Found this solution on youtube, credit to Maker At Playing Code I found https://www.youtube.com/watch?v=oKFb2Us9kmgJavaScript Date Object and Time Zones | Fixing an "off by 1 day" bug

  on YouTube. This fixes/resets the offset for the local timezone. GreatThere's a great explanation to this problem in the video.

// date as YYYY-MM-DDT00:00:00Z

let dateFormat = new Date(date)

// Methods on Date Object will convert from UTC to users timezone
// Set minutes to current minutes (UTC) + User local time UTC offset

dateFormat.setMinutes(dateFormat.getMinutes() + dateFormat.getTimezoneOffset())

// Now we can use methods on the date obj without the timezone conversion

let dateStr = dateFormat.toDateString();

Found this solution on youtube, credit to Maker At Playing Code https://www.youtube.com/watch?v=oKFb2Us9kmg

  This fixes/resets the offset for the local timezone. Great explanation to this problem in the video.

// date as YYYY-MM-DDT00:00:00Z

let dateFormat = new Date(date)

// Methods on Date Object will convert from UTC to users timezone
// Set minutes to current minutes (UTC) + User local time UTC offset

dateFormat.setMinutes(dateFormat.getMinutes() + dateFormat.getTimezoneOffset())

// Now we can use methods on the date obj without the timezone conversion

let dateStr = dateFormat.toDateString();

I found JavaScript Date Object and Time Zones | Fixing an "off by 1 day" bug on YouTube. This fixes/resets the offset for the local timezone. There's a great explanation to this problem in the video.

// date as YYYY-MM-DDT00:00:00Z

let dateFormat = new Date(date)

// Methods on Date Object will convert from UTC to users timezone
// Set minutes to current minutes (UTC) + User local time UTC offset

dateFormat.setMinutes(dateFormat.getMinutes() + dateFormat.getTimezoneOffset())

// Now we can use methods on the date obj without the timezone conversion

let dateStr = dateFormat.toDateString();

added 7 characters in body
Source Link
K__lite
  • 171
  • 1
  • 4

Found this solution on youtube, credit to Maker At Playing Code https://www.youtube.com/watch?v=oKFb2Us9kmg

This fixes/resets the offset for the local timezone. Great explanation to this problem in the video.

// date as YYYY-MM-DDT00:00:00Z

let dateFormat = new Date(date)

// Methods on Date Object will covertconvert from UTC to users timezone
// Set minutes to current minutes (UTC) + User local time UTC offset

dateFormat.setMinutes(dateFormat.getMinutes() + dateFormat.getTimezoneOffset())

// Now we can use methods on the date obj without the timezone conversion

let dateStr = dateFormat.toDateString();

Found this solution on youtube, credit to Maker At Playing Code https://www.youtube.com/watch?v=oKFb2Us9kmg

This fixes the offset for the local timezone. Great explanation to this problem in the video.

// date as YYYY-MM-DDT00:00:00Z

let dateFormat = new Date(date)

// Methods on Date Object will covert from UTC to users timezone
// Set minutes to current minutes (UTC) + User local time UTC offset

dateFormat.setMinutes(dateFormat.getMinutes() + dateFormat.getTimezoneOffset())

// Now we can use methods on the date obj without the timezone conversion

let dateStr = dateFormat.toDateString();

Found this solution on youtube, credit to Maker At Playing Code https://www.youtube.com/watch?v=oKFb2Us9kmg

This fixes/resets the offset for the local timezone. Great explanation to this problem in the video.

// date as YYYY-MM-DDT00:00:00Z

let dateFormat = new Date(date)

// Methods on Date Object will convert from UTC to users timezone
// Set minutes to current minutes (UTC) + User local time UTC offset

dateFormat.setMinutes(dateFormat.getMinutes() + dateFormat.getTimezoneOffset())

// Now we can use methods on the date obj without the timezone conversion

let dateStr = dateFormat.toDateString();

deleted 7 characters in body
Source Link
K__lite
  • 171
  • 1
  • 4

Found this solution on youtube, credit to Maker At Playing Code https://www.youtube.com/watch?v=oKFb2Us9kmg&t=586shttps://www.youtube.com/watch?v=oKFb2Us9kmg

This fixes the offset for the local timezone. Great explanation to this problem in the video.

// date as YYYY-MM-DDT00:00:00Z

let dateFormat = new Date(date)

// Methods on Date Object will covert from UTC to users timezone
// Set minutes to current minutes (UTC) + User local time UTC offset

dateFormat.setMinutes(dateFormat.getMinutes() + dateFormat.getTimezoneOffset())

// Now we can use methods on the date obj without the timezone conversion

let dateStr = dateFormat.toDateString();

Found this solution on youtube, credit to Maker At Playing Code https://www.youtube.com/watch?v=oKFb2Us9kmg&t=586s

This fixes the offset for the local timezone. Great explanation to this problem in the video.

// date as YYYY-MM-DDT00:00:00Z

let dateFormat = new Date(date)

// Methods on Date Object will covert from UTC to users timezone
// Set minutes to current minutes (UTC) + User local time UTC offset

dateFormat.setMinutes(dateFormat.getMinutes() + dateFormat.getTimezoneOffset())

// Now we can use methods on the date obj without the timezone conversion

let dateStr = dateFormat.toDateString();

Found this solution on youtube, credit to Maker At Playing Code https://www.youtube.com/watch?v=oKFb2Us9kmg

This fixes the offset for the local timezone. Great explanation to this problem in the video.

// date as YYYY-MM-DDT00:00:00Z

let dateFormat = new Date(date)

// Methods on Date Object will covert from UTC to users timezone
// Set minutes to current minutes (UTC) + User local time UTC offset

dateFormat.setMinutes(dateFormat.getMinutes() + dateFormat.getTimezoneOffset())

// Now we can use methods on the date obj without the timezone conversion

let dateStr = dateFormat.toDateString();

Source Link
K__lite
  • 171
  • 1
  • 4
Loading