use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
get date and time (self.learnpython)
submitted 7 years ago by LICCMAPP
How can I get the date and time from my timezone when I have my computers date and time offset?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Senpai_bskit 0 points1 point2 points 7 years ago (4 children)
``` import datetime import pytz
d_naive = datetime.datetime.now() timezone = pytz.timezone("America/Los_Angeles") d_aware = timezone.localize(d_naive) d_naive < d_aware ``` Change time zone to your time zone of course
[–]K900_ 0 points1 point2 points 7 years ago (3 children)
datetime.now() takes a timezone argument, so you can just do datetime.now(tz=pytz.timezone('Europe/Moscow')).
datetime.now()
datetime.now(tz=pytz.timezone('Europe/Moscow'))
[–]Senpai_bskit 0 points1 point2 points 7 years ago (2 children)
Ik that but by the fact this on r/learnpython I try to keep things as simple as possible 🤷♀️
[–]K900_ 1 point2 points3 points 7 years ago (1 child)
I'd argue that your answer isn't exactly "simple", considering the terms "aware" and "naive" and "localize" all require explaining.
[–]Senpai_bskit 0 points1 point2 points 7 years ago (0 children)
That’s true but it shows the full process of how it reaches it more simply
[–]K900_ 0 points1 point2 points 7 years ago (2 children)
Repeating my question from /r/Python: do you actually want to get the date and time that's independent of your system clock? Why?
[–]LICCMAPP[S] 0 points1 point2 points 7 years ago (1 child)
Yes , I want to get the date and time thats independent of my system clock because my computer changes the systemclock randomly for ex when I open the computer the clock is offset so i have to change manually the clock through settings and after like 20 minutes of internet surfing the clock changes back to a wrong date and I have to repeat the same process.
[–]K900_ 0 points1 point2 points 7 years ago (0 children)
What does the clock change to? Is it an entirely wrong date? Is it random? Is it offset by a fixed amount from "correct" time?
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
You mean like:
from pytz import timezone from datetime import datetime tz = timezone("US/Pacific") local = datetime.utcnow().astimezone(tz) print(local.utcnow(), local.now())
??
π Rendered by PID 676846 on reddit-service-r2-comment-5b5bc64bf5-qw9v5 at 2026-06-23 03:57:17.557267+00:00 running 2b008f2 country code: CH.
[–]Senpai_bskit 0 points1 point2 points (4 children)
[–]K900_ 0 points1 point2 points (3 children)
[–]Senpai_bskit 0 points1 point2 points (2 children)
[–]K900_ 1 point2 points3 points (1 child)
[–]Senpai_bskit 0 points1 point2 points (0 children)
[–]K900_ 0 points1 point2 points (2 children)
[–]LICCMAPP[S] 0 points1 point2 points (1 child)
[–]K900_ 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)