How to convert 2019-09-05T11:31:34.059Z this DateTime to offset 260.
database:mssql, datatype:datetimeoffset(7).
As one can identify current time-offset then how to convert the given date to this time-offset
How to convert 2019-09-05T11:31:34.059Z this DateTime to offset 260.
database:mssql, datatype:datetimeoffset(7).
As one can identify current time-offset then how to convert the given date to this time-offset
You can convert to prefered time zone by following way ,
new Date().toLocaleString("en-US", {timeZone: "America/New_York"})
<html>
<head>
<script language="JavaScript">
// function to calculate local time
// in a different city
// given the city's UTC offset
function calcTime(city, offset) {
// create Date object for current location
d = new Date();
// convert to msec
// add local time zone offset
// get UTC time in msec
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// create new Date object for different city
// using supplied offset
nd = new Date(utc + (3600000*offset));
// return time as a string
return "The local time in " + city + " is " + nd.toLocaleString();
}
// get Bombay time
alert(calcTime('Bombay', '+5.5'));
// get Singapore time
alert(calcTime('Singapore', '+8'));
// get London time
alert(calcTime('London', '+1'));
</script>
</head>
<body>
</body>
</html>
If you are convenient with 3rd party libraries, you can go with moment.js along with moment-tz (moment with timezone).