I want a date-time object in UTC time, and not a UTC date-time string.
The following code helps me to get the UTC time as a string:
moment.parseZone(new Date()).utc().format()
The output of the code above is:
"2019-01-14T12:43:23Z"
The above is a string, which I do not want. What I want is a date-time object. This is how I convert a date-time string to a date-time object:
new Date(moment.parseZone(new Date()).utc().format())
Unfortunately the above code coverts the output into local time AGAIN, an example of which is shown below:
Mon Jan 14 2019 18:10:54 GMT+0530 (India Standard Time)
How do we stop a UTC date-time object from converting to local date-time?
Edit-01: How do I perform calculations using a date-time object in UTC time?
Edit-02: Functional Explanation:
There are people with different time zones. We know the UTC time difference. I want to build a table of each persons’ time in their local time.
Example: My timezone is +5:30 UTC (my time is currently 01/14/2019 9:00pm) and a person from San Francisco has a timezone of -8:00 UTC (his/her time is currently 01/14/2019 7:30am).
At present, what I am trying to do is add the time difference (-8:00 UTC) to UTC time to find San Francisco person’s local time. This does not work because when I convert the UTC date-time string to a date object it will convert into local time.