Is there a way, in linux, to problematically get UTC time for a given time string like
Tue Dec 14 10:30:23 PST 2012
Tue Jan 4 11:30:23 EST 2013
to a UTC time, irrespective of( and without changing) local time zone settings?
Is there a way, in linux, to problematically get UTC time for a given time string like
Tue Dec 14 10:30:23 PST 2012
Tue Jan 4 11:30:23 EST 2013
to a UTC time, irrespective of( and without changing) local time zone settings?
date -u -d "Tue Dec 14 10:30:23 PST 2012"
reportsFri Dec 14 18:30:23 UTC 2012
. The discrepancy is because Dec 14 2012 is in fact a Friday, not a Tuesday. It probably works better with valid input...Update: the result with the recent tz database is different: EST yields the same utc offset for a given date (compare with the previous result). Though it does not affect the general conclusion that different timezones may use the same abbreviation and therefore the same abbreviation may correspond to different utc offsets. See Parsing date/time string with timezone abbreviated name in Python?
Abbreviated timezone names such as EST may be ambiguous.
Example
Output
Two things:
date
silently ignoresAustralia/Brisbane
timezone that should beUTC+10
i.e.,date
interpretsEST
as belonging to a different timezone. WithoutEST
it produces correct time:To find all possible UTC times for given time and timezone abbreviation e.g., for
'Tue Jan 4 11:30:23 EST 2013'
:Output
All
Tue Jan 4 11:30:23 EST 2013
interpretations as UTC with corresponding timezone names: