I was trying to add give timezone to the current UTC time but getting a syntax error and I m not able to fix it ..my desired output is-"2021-03-17T17:35:31.621Z+0530" and the condition is that timezone will be given by user ,it's not fixed and my code in python is:
import datetime,time sent_at=datetime.datetime.utcfromtimestamp(time.time())+t="+0530" hours =int(t[1:3]) minutes =int(t[3:5]) v= hours*60*60 +minutes*60 need_time=time.time()+v result_time=datetime.datetime.utcfromtimestamp(need_time)).strftime('%Y-%m-%dT%H:%M:%S.%f') [:-3]+'Z'+'+0530' ...... I am doing this much code because I don't understand how to add a string type timezone to a current UTC time...and after all this, I am getting syntax error
https://stackoverflow.com/questions/66714839/what-will-be-the-correct-syntax-of-i-m-trying-to-add-given-timezone-to-the-curr March 20, 2021 at 03:55AM
没有评论:
发表评论