About 50 results
Open links in new tab
  1. python - What is the difference between strptime and strftime? - Stack ...

    Oct 21, 2018 · strptime converts the string to a datetime object. strftime creates a formatted string for given time/date/datetime object according to specified format by the user you would use strftime to …

  2. How do I get a string format of the current date time, in python?

    You can use the datetime module for working with dates and times in Python. The strftime method allows you to produce string representation of dates and times with a format you specify.

  3. How do I turn a python datetime into a string, with readable format ...

    The datetime class has a method strftime. The Python docs documents the different formats it accepts: strftime () and strptime () Behavior For this specific example, it would look something like:

  4. Getting today's date in YYYY-MM-DD in Python? - Stack Overflow

    Since Python 3.9, you can use the built-in zoneinfo library to get timezones. Then once you get today's date as a datetime.datetime object, it's straightforward to convert to a string in the desired format …

  5. Python strftime - date without leading 0? - Stack Overflow

    May 25, 2009 · When using Python strftime, is there a way to remove the first 0 of the date if it's before the 10th, ie. so 01 is 1? Can't find a %thingy for that? Thanks!

  6. How to use %f with strftime () in Python to get microseconds?

    I'm trying to use strftime() to microsecond precision, which seems possible using %f (as stated here). However when I try the following code: import time import strftime from time print strftime(&...

  7. Converting a string to a formatted date-time string using Python

    Dec 29, 2009 · answered May 10, 2015 at 5:42 Raphael Amoedo 4,515 4 32 39 python datetime time strftime strptime

  8. python - Format a datetime into a string with milliseconds - Stack …

    How can I format a datetime object as a string with milliseconds?

  9. Python Datetime : use strftime() with a timezone-aware date

    Apr 19, 2009 · Python Datetime : use strftime () with a timezone-aware date Asked 8 years ago Modified 7 months ago Viewed 168k times

  10. Why does `strftime("%Y")` not yield a 4-digit year for dates < 1000 AD ...

    Apr 23, 2025 · I am puzzled by an inconsistency when calling .strftime () for dates which are pre-1000 AD, using Python's datetime module. Take the following example: import datetime old_date = …