Can anyone help me in converting the below date format into the preferred format?
"Tue Dec 08 18:00:00 IST 2020"
preferred format:
2020-12-08 18:00:00 +05:30
Can anyone help me in converting the below date format into the preferred format?
"Tue Dec 08 18:00:00 IST 2020"
preferred format:
2020-12-08 18:00:00 +05:30
This is not possible because time zone abbreviations are not well defined, and many are not unique.
For example, there are 3 different interpretations of IST
:
You seem to be asking about the first one, but there's no way for a computer to know that when you are considering all of the time zones of the world.
The list of possibilities gets a bit crazy if you start thinking about other details, such as:
Thus, you cannot just convert whatever abbreviation might be in your string to the correct offset. Instead, you need to generate the string such that it already has the offset in it, or you need additional information - such as a time zone identifier (e.g.: "Asia/Kolkata"
), or at least a country code and language to help disambiguate the abbreviation.