When retrieving data from the API, I encounter Date, Time, and Offset values in separate columns. My goal is to obtain an ISO date while maintaining the original date and time values.
const date = "2019-04-15"
const time = "13:45"
const offset = 1 // It can be negative like -4 or -5
The desired output is "2019-04-15T13:45:00+01:00", where the date, time, and offset remain unchanged.
If the offset for the same datetime is -4, then the output should be "2019-04-15T13:45:00-04:00".
To achieve this, I am using the following code:
moment(date+'T'+time).utcOffset(offset).format();
However, the current output is "2019-04-15T12:45:00+01:00" as it adjusts the time based on the offset value, which is not the desired outcome.