Skip to Content
Menu
This question has been flagged
1 Reply
2247 Views

Hello,

I'm converting time with respect of country timezone,

Time is showing correct but timezone is showing incorrect,

For India and some other country:

Fri,Mar 19,2021 01:30 PM-11:30 PM IST


But For UAE and Afganitans 

 Fri,Mar 19,2021 12:00 PM-10:00 PM +04


In above example 

for india timezone is showing IST 

but for UAE and Afganistans it's showing +"04"

I need to show GMT there,

print(datetime.now().astimezone(pytz.timezone("Asia/Dubai")).strftime("%a,%b %d,%Y %I:%M %p %Z"))

Avatar
Discard
Best Answer

Hi,

   Here am getting the currently logged in Users date and time with zone .

date3 = fields.datetime.now(pytz.timezone(self.env.user.tz or 'GMT')).strftime("%d-%m-%Y %H:%M:%S:%z")

    %z - This shows whether the time is ahead or behind the GMT like + "04".

    %Z - This  shows the name of the timezone like IST
you can check this link too https://www.w3schools.com/python/gloss_python_date_format_codes.asp

Thanks

Avatar
Discard
Author

Thanks for help.

Hi,

Glad to help, is it working now? If so please mark as the correct answer and close this one.