Discussions

Check out Oracle NetSuite upcoming events and conferences here
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
Update your Profile with your Support type to get your Support Type badge.
Expand your NetSuite knowledge by joining our Ask A Guru Live sessions. RSVP on this event now.
Community Poll: What sort of content would you like to see more of?

getTimezoneOffset() of Date Object

edited Nov 20, 2023 7:26AM in Ask A Guru 5 comments

The following block doesn't work as we expected.

function getNonDstTimeZoneOffset(date) {
    const january1st = new Date(date.getFullYear(), 0, 1)
    const july1st = new Date(date.getFullYear(), 6, 1)
    return Math.max(january1st.getTimezoneOffset(), july1st.getTimezoneOffset())
  }
//january1st.getTimezoneOffset() = 480 (should be -540...)
//july1st.getTimezoneOffset() = 420 (should be -480? though we don't have DST...)

  function resetDateWithCurrentTimeZone(utcDate) {
    if (!utcDate) {
      utcDate = new Date()
//EX) "2023-11-20T07:03:29.492Z"
    }
    const timezoneOffset = utcDate.getTimezoneOffset()
    const nonDstTimezoneOffset = getNonDstTimeZoneOffset(utcDate)
    log.audit("==UTCDate & LocalOffset==", {
      utcDate: utcDate,
  
Tagged:

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!

Leaderboard

Community Whiz

Quarter 1 (Jan-Mar 2024)

This Week's Leaders

This Month's Leaders

All Time Leaders