Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get date in specific timezone

function getTimeFromTimezone(offset) {  
  const currentDate = new Date() //get current time to calculate the UTC time
  let utc = currentDate.getTime() + (currentDate.getTimezoneOffset() * 60000) //calculates the UTC time
  let nd = new Date(utc + (3600000*offset)) // get the current timezone with the offset
  return nd
}

getTimeFromTimezone('+5.5').toLocaleString()
getTimeFromTimezone('-3').toLocaleString()
 
PREVIOUS NEXT
Tagged: #date #specific #timezone
ADD COMMENT
Topic
Name
5+5 =