Change chart time from UTC to IST in tradingview lightweight-chart - lightweight-charts

I plotted the ohlc data using UTC Timestamp (converted from IST). For e.g., 2021-01-01 09:15:00+05:30 => 1609472700
In the plot, time in the x-axis shows as UTC time, not in IST, i.e., 2021-01-01 03:45.
How to change this?

Related

SQL Server - convert UTC to EST (include Daylight Savings, when appropriate)

I have a table that stores the transaction date time in UTC time zone. I would need to convert this time to eastern time zone i.e. EST or EDT, depending on the transaction date.
How can I do this without writing a big function or creating a table / view that flags EST / EDT for each transaction date?
Use AT TIME ZONE, which changes the timezone of a value to the relevant time there, and observes Daylight Saving:
SELECT CONVERT(datetimeoffset(0),'2021-09-07T15:25:37+00:00') AT TIME ZONE 'Eastern Standard Time' AS Sep21,
CONVERT(datetimeoffset(0),'2021-01-09T15:25:37+00:00') AT TIME ZONE 'Eastern Standard Time' AS Jan21;
Which returns the following:
Sep21 Jan21
---------------------------------- ----------------------------------
2021-09-07 11:25:37 -04:00 2021-01-09 10:25:37 -05:00

how to convert UTC date/time into MDT and military time for react application?

I am trying to convert UTC into MDT (mountain time) format. I am not sure which moment format require to convert date time into MDT. i tried moment.fromOADate(41493) but not working. TIA!
Mountain time is GMT -6, so you should be able to use moment().utcOffset(-6)
https://en.wikipedia.org/wiki/Mountain_Time_Zone
https://momentjscom.readthedocs.io/en/latest/moment/03-manipulating/09-utc-offset/
If you're worried about accounting for daylight savings time and can't just subtract 6 hours, you might also look into the moment.js timezone library.
You could say something like is described here and do var zone = moment.tz.zone('America/Chihuahua') (this is mountain time), then get your time offset with zone.parse(utcTimestamp)

angularjs Date Daylightsaving issue

I am using date to display my date on html like:
{{updateDate| date: 'dd/MM/yyyy HH:mm:ss'}}
Dates are all saved in UTC. The problem is it displays the date in locale timezone but not considering Daylight saving on/off. As in for BST it always shows +1 hr from UTC.
I want it to also consider DST(daylight saving time).
Any help, please.
{{ date_expression | date : format : timezone}}
As per angular date filter documentation:
date: Here date can be Date Object, milliseconds or ISO 8601 datetime string formats (like: e.g. yyyy-MM-ddTHH:mm:ss.sssZ). Here Z is 4 digit (+sign) representation of the timezone offset (-1200-+1200). If no timezone is specified in the string input, the time is considered to be in the local timezone.
format: this is optional, If not specified, mediumDate(equivalent to 'MMM d, y' for en_US locale (e.g. Sep 3, 2010)) is used.
timezone: Timezone to be used for formatting. It understands UTC/GMT and the continental US time zone abbreviations, but for general use, use a time zone offset, for example, '+0430' (4 hours, 30 minutes east of the Greenwich meridian) If not specified, the timezone of the browser will be used.
This may help you.

Find out client time zone in UTC format in Angularjs

Is there some way to find out what is the time zone of a user, in UTC format(like UTC+1, UTC+2,...etc)
What I am trying to accomplish is that after user selects UTC time zone from drop down and selects time and date, I want to show date and time values in his time zone (time zone from browser or system).
So if for example user selects: UTC+2 and 13:00 11-03-2016 and his system time zone is UTC than I want to show in some label: In your time that is: 11:00 11-03-2016 (since the UTC is minus 2 hours comparing to UTC+2)
Does somebody has suggestions on how to accomplish something like this?
Just create new Date object without specifying the time zone - JavaScript will use the browser's time zone and when getting a date, without specifying the time zone, the result is converted to the browser's time zone.
Please review examples on http://www.w3schools.com/js/js_dates.asp
Hope it will help. Handling dates in js and angular is a bit tricky;)

moment to date object timezone issue

I have a moment.js object generated from fullcalendar in BST that looks like this:
console.log(momentSelected)
//Moment {_isAMomentObject: true, _isUTC: true, _offset: 0, _locale: f, _d: Tue May 03 2016 01:00:00 GMT+0100 (BST)…}
I don't want a BST time but a UTC time that looks like this:
console.log(momentSelected.format('YYYY-MM-DD HH:mm Z'));
//2016-05-03 00:00 +00:00
Now I need to convert it into a Date object:
$scope.date = new Date(momentSelected.format('YYYY-MM-DD HH:mm Z'));
console.log($scope.date);
//Wed May 04 2016 01:00:00 GMT+0100 (BST)
The last output is wrong... I want Wed May 04 2016 00:00:00+00:00 (UTC)
You can create a Date object using the toDate function on the moment object.
$scope.date = momentSelected.toDate();
However, you must recognize that the nature of the Date object is that it will always represent UTC internally, and its toString function will always reflect the local time zone where the code is running.
If your local time zone is UK (alternating between GMT and BST for daylight saving time), then it is impossible to get (UTC) time in the string produced by console.log($scope.date);, regardless of how you created that date.
This is why it is better to use moment's format function and display that string directly. A moment can reflect UTC, local time, and other time zones. A Date object cannot.
Also, you should pay no attention to the underscore-prefixed internal fields of a moment object. Use the public API instead. See the moment user guide.

Resources