get user time using timezone javascript
function calcTime(city, offset) {
// create Date object for current location
var d = new Date();
// convert to msec
// subtract local time zone offset
// get UTC time in msec
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// create new Date object for different city
// using supplied offset
var nd = new Date(utc + (3600000*offset));
// return time as a string
return "The local time for city"+ city +" is "+ nd.toLocaleString();
}
alert(calcTime('Bombay', '+5.5'));
Also in JavaScript:
- [JsonConverter(typeof(StringEnumConverter))] on list of enums
- javascript sleep function
- javascript create element in a new line
- javascript insertBefore
- creating a 2d array in js
- mongoose save return id
- json decode android
- How can I check whether a variable is defined in Node Js
- react dark mode npm
- how to convert array converted to string back to array javasccript
- react map wait axios call
- sleep javascript
- e.target javascript
- cannot concatenate object of type "<class 'str'>"; only pd.Series, pd.DataFrame, and pd.Panel (deprecated) objs are valid
- get the state of a checkbox
- javascript sum of array
- vue axios catch error
- adding int and string in react props
- jquery ajax form submission
- how to create monorapo project in angular 8
- javascript round up
- Sets can be used to store __________. in js
- what is nodes and hubs in selenium grid
- material-ui icon compass