Want a #Python datetime with a timezone? Use the "zoneinfo" module: import zoneinfo tz = zoneinfo.ZoneInfo('US/Eastern') Then pass it to the "tzinfo" keyword arg: dt = datetime.datetime(2026, 4, 1, 13, tzinfo=tz)
Python datetime with US Eastern timezone using zoneinfo
More Relevant Posts
-
🔄 Input & Output in Python input() → take user input print() → show output Use case: Take server name → display status Simple but powerful. #PythonBasics
To view or add a comment, sign in
-
Having a tough time remembering #Python strptime vs. strftime? - The "p" (strptime) is for parsing, getting a datetime from a string - The "f" (strftime) is for formatting, getting a string from a datetime For help remembering the format codes, turn to https://buff.ly/oEdYGMI !
To view or add a comment, sign in
-
-
Dashboard with DASH. Using a series of synthetic data, I created this dashboard using the DASH library in Python, but I must admit that it's easier to work with the Shainy library in R. Which do you prefer? The advantages of using these two libraries I just mentioned are that they are completely free and that you can also share and interact with the image in a professional meeting without having to pay a single cent. This is much more expensive with other solutions. #DataVisualization #PythonProgramming #BusinessIntelligence
To view or add a comment, sign in
-
-
If a #Python string contains an ISO-formatted date, skip strptime and use datetime.fromisoformat: import datetime as dt dt.datetime.fromisoformat('2026-04-12') # returns datetime at midnight dt.datetime.fromisoformat('2026-04-12 12:34:56') # returns datetime at 12:34:56
To view or add a comment, sign in
-
-
📊 Python Program: Find Maximum Value ```python numbers = [10, 25, 5, 40, 15] max_value = max(numbers) print("Max Value:", max_value) ``` 💡 Real use: ✔ Finding peak CPU usage ✔ Monitoring data #Python #DataHandling
To view or add a comment, sign in
-
Want to take a #Python #Pandas series of strings, and get datetime values? Use pd.to_datetime: pd.to_datetime(df['x']) Notice: It's not a method! It's a top-level pd function. Specify a non-standard "format" with a strftime string: pd.to_datetime(df['x'], format='%d/%m/%Y')
To view or add a comment, sign in
-
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Oooh, shiny. We used `pytz` for our project when I was at Meta. I remember making an active decision to use `pytz` over `zoneinfo`, in 2024, but I annoyingly can't remember why. Think we might have still been on 3.8 at the time. Anyway I remember dealing with all our time conversions being off by seven minutes... still traumatised. Seems like there's no good reason to use `pytz` over `zoneinfo` these days. https://www.reddit.com/r/Python/comments/1kxxgf9/python_timezone_conversion_gotcha_zoneinfo_vs_pytz/