I am working on a robotics project which has sensor data from different locations with millisecond precision (gps synchronised ntp to within 1ms).
How to convert historical date, time and UTC offset components into milliseconds since unix epoch? That is, all YYYY-mm-dd HH:MM:SS.mS +/-UTC offset
are available as individual integers and not a string.
The offset accounts for daylight savings so for example a timezone of UTC +1 will have a UTC offset of +2 during daylight savings.
There is a similar post however it dealt with a datetime in a string format with no UTC offset information.
The accepted answer from that post was to use mktime
however in this post a 60K+ rep user commented that:
mktime will use your computer's locale to convert that date/time into GMT. If you do not want to have your local timezone subtracted, then use mkgmtime.
I've confirmed that mktime
does perform timezone conversions which are dependent on the daylight savings flag tm_isdst
. I don't have information whether or not the observations were taken during daylight savings or not, only their offset to UTC.
What is a robust way to convert historical datetimes with UTC offsets into milliseconds since unix epoch?
local_date_time
, where thelocal_date_time
was set using the unadjusted datetime values? – user6835678