Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

datetime

How to subtract a day from a date?

August 21, 2022 by Magenaut

I have a Python datetime.datetime object. What is the best way to subtract one day?

Categories Python, Q&A Tags date, datetime, python Leave a comment

How to make a timezone aware datetime object

August 21, 2022 by Magenaut

What I need to do

Categories Python, Q&A Tags datetime, python, python-datetime, pytz, timezone Leave a comment

How to preserve timezone when parsing date/time strings with strptime()?

August 21, 2022 by Magenaut

I have a CSV dumpfile from a Blackberry IPD backup, created using IPDDump.
The date/time strings in here look something like this
(where EST is an Australian time-zone):

Categories Python, Q&A Tags datetime, python, timezone Leave a comment

Extracting just Month and Year separately from Pandas Datetime column

August 21, 2022 by Magenaut

I have a Dataframe, df, with the following column:

Categories Python, Q&A Tags datetime, pandas, python Leave a comment

Convert python datetime to epoch with strftime

August 21, 2022 by Magenaut

I have a time in UTC from which I want the number of seconds since epoch.

Categories Python, Q&A Tags datetime, epoch, python, strftime, utc Leave a comment

How can I convert a datetime object to milliseconds since epoch (unix time) in Python?

August 20, 2022 by Magenaut

I have a Python datetime object that I want to convert to unix time, or seconds/milliseconds since the 1970 epoch.

Categories Python, Q&A Tags datetime, epoch, python Leave a comment

Convert pandas timezone-aware DateTimeIndex to naive timestamp, but in certain timezone

August 20, 2022 by Magenaut

You can use the function tz_localize to make a Timestamp or DateTimeIndex timezone aware, but how can you do the opposite: how can you convert a timezone aware Timestamp to a naive one, while preserving its timezone?

Categories Python, Q&A Tags datetime, pandas, python, timezone Leave a comment

What is the standard way to add N seconds to datetime.time in Python?

August 20, 2022 by Magenaut

Given a datetime.time value in Python, is there a standard way to add an integer number of seconds to it, so that 11:34:59 + 3 = 11:35:02, for example?

Categories Python, Q&A Tags datetime, math, python, time Leave a comment

How to parse dates with -0400 timezone string in Python?

August 20, 2022 by Magenaut

I have a date string of the form ‘2009/05/13 19:19:30 -0400’. It seems that previous versions of Python may have supported a %z format tag in strptime for the trailing timezone specification, but 2.6.x seems to have removed that.

Categories Python, Q&A Tags datetime, python, timezone Leave a comment

Get date from week number

August 20, 2022 by Magenaut

Please what’s wrong with my code:

Categories Python, Q&A Tags datetime, python, strptime Leave a comment
Older posts
Newer posts
← Previous Page1 … Page7 Page8 Page9 … Page20 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress