Convert iso8601_micro date format into local date/time and local timezone

Latest response


I've been racking my brain on this and unable to find any samples of how to convert iso8601_micro date/time format into my localtime with timezone. I've been able to convert it as far as getting the UTC value but I need to make it so it shows the local time convert to locall timezone.

I'm basically taking this value from tower to show when a host was created in an inventory so I can either keep it there or delete it. If anyone has any great ideas please come forward!

Thank you.



Hi Glen,

I hope I understand your question correctly.

There are many ways to convert ISO8601 to standard time.

Here is one Bash-style example:

loctime=$(date -d"TZ=\"${timeZone}\" $var")
echo $loctime


Dusan Baljevic (amateur radio VK2COT)

Hello. Thanks for the reply. And I feel stupid.....I left out one important bit of information. I'd like to do this is native ansible. This date/time format is an internal field in the ansible tower inventory which I can to do some comparisons against. There is no jinga template built into ansible that will convert the iso format. At least not that I have found.