-1

I have a data frame with a date time string in UCT in the following format:

2022-06-05T07:01:00.000Z

I am trying to convert the date time string to local time (GMT+3).

I have tried few methods but with no luck. Can you please help.

SM1987
  • 9
  • Does this answer your question? [Python Timezone conversion](https://stackoverflow.com/questions/10997577/python-timezone-conversion) – Pranav Hosangadi Jun 06 '22 at 21:00
  • Note that "I have tried a few methods but no luck" isn't a question. You need to _show what you tried_ and ask a _specific question_ about the problem you encountered with a [mre]. Please take the [tour] and read [what's on-topic here](/help/on-topic), [ask], and the [question checklist](//meta.stackoverflow.com/q/260648/843953). – Pranav Hosangadi Jun 06 '22 at 21:01
  • Does this answer your question? [How do I parse an ISO 8601-formatted date?](https://stackoverflow.com/questions/127803/how-do-i-parse-an-iso-8601-formatted-date) – FObersteiner Jun 07 '22 at 04:57

1 Answers1

0

Be so kind, read documentation first: https://docs.python.org/3.10/library/datetime.html

As the documentation suggested, you have to use https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.isoparse rather than original fromisoformat https://docs.python.org/3.10/library/datetime.html#datetime.datetime.fromisoformat

It will return datetime so that will provide you an option to replace timezone like so: .replace(tzinfo=timezone.utc).astimezone(tz=None).

Maxja
  • 435
  • 1
  • 4
  • 14