I am running a program that requests ocean tide data from a remote server. The time
and date
of this tide data is being computed based on my machine's local time zone. I want to use these local dates and times to create a datetime
object, which I will then save in a Django model.
datetime_obj = datetime(loc_year, loc_month, loc_date, loc_hour, loc_minute)
How do I ensure that the datetime
object is aware that it was created based on a local time zone, before posting it to Django?
I guess, I would want it to look like this before posting it:
datetime_obj = datetime(loc_year, loc_month, loc_date, loc_hour, loc_minute, loc_timezone)
How do I get the local timezone of my machine dynamically? And how to I ensure that all users see the time converted to their own local timezone.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…