Python
docs.python.org βΊ 3.6 βΊ library βΊ datetime.html
8.1. datetime β Basic date and time types β Python 3.6.15 documentation
Return a string representing the time, controlled by an explicit format string. For a complete list of formatting directives, see strftime() and strptime() Behavior.
GeeksforGeeks
geeksforgeeks.org βΊ python βΊ python-strftime-function
Python strftime() function - GeeksforGeeks
July 12, 2025 - from datetime import datetime now = datetime.now() print(now) # Format: Abbreviated weekday, month, 2-digit year f_1 = now.strftime("%a %m %y") print(f_1) # Format: Full weekday, full year f_2 = now.strftime("%A %m %Y") print(f_2) # Format: 12-hour time with AM/PM and seconds f_3 = now.strftime("%I %p %S") print(f_3) # Format: Day of the year f_4 = now.strftime("%j") print(f_4)
Videos
06:57
Python - How to use strftime(), to format date and time values. ...
01:35
How to Format Dates and Times in Python with strftime() - YouTube
05:21
strptime, strftime in datetime explained clearly - Python - YouTube
14:45
Python for Beginners | L26: Strftime and Strptime Methods in Python ...
22:34
Python Datetime strftime Function | Part - 3 - YouTube
10:31
43. π
Master Date & Time Formatting in Python β° | strftime ...
Python documentation
docs.python.org βΊ 3 βΊ library βΊ datetime.html
datetime β Basic date and time types
2006 # year 11 # month 21 # day 16 # hour 30 # minute 0 # second 1 # weekday (0 = Monday) 325 # number of days since 1st January -1 # dst - method tzinfo.dst() returned None >>> # Date in ISO format >>> ic = my_datetime.isocalendar() >>> for it in ic: ... print(it) ... 2006 # ISO year 47 # ISO week 2 # ISO weekday >>> # Formatting a datetime >>> my_datetime.strftime("%A, %d.
strftime
strftime.org
Python strftime reference cheatsheet
A quick reference for Python's strftime formatting directives.
Reddit
reddit.com βΊ r/learnpython βΊ difference between strftime and datetime??
r/learnpython on Reddit: Difference between strftime and datetime??
August 19, 2017 -
So yesterday I was working with an excel file and I wanted to have a way to include the exact date of that file's creation in the file name. So I used strftime. But I also know that there is a datetime function. Previously, I've never worked with either of these functions, so I can't claim to understand the differences. Which is why I wanted to ask here. What are the differences between these two functions and modules? The time module and the date time module that is.
Top answer 1 of 3
6
datetime gives you an object that is used in python for time representation and manipulation. >>> from datetime import datetime >>> now = datetime.now() >>> now datetime.datetime(2017, 8, 19, 14, 14, 59, 637824) >>> type(now) >>> now - datetime(2000,1,1,0,0,0) datetime.timedelta(6440, 51299, 637824) It doesn't have any format to speak of, it's just a object with numbers for year, month, day, hours, minutes, seconds, and the subsecond crap. You can do math on it. Given that datetime itself has no format, a function capable of doing so is necessary. Strftime (string format time) is that function. It takes the value of the object and produces a string representation in a given format that uses a bunch of %X flags that stand for different things, so you can use that string for printing nice dates and name things with it. >>> now.strftime('%A') 'Saturday' >>> now.strftime('%B') 'August' >>> now.strftime('%Y-%m-%d') '2017-08-19' https://docs.python.org/3/library/datetime.html there is also strptime (string parse time) that goes in the opposite direction - it is capable of parsing a string containing date and produce the kosher datetime object.
2 of 3
2
Time.strftime let's you take all the date/time information and put it in a specific format. It's really useful if you want to output the time, date or both in a specific way. Like I could put out the time in the format: Hour-minute-second time.strftime('%-I-%M-%-S') Or like this Hour:minute:second time.strftime('%-I:%M:%-S') And you can do a lot more with it and add words to it as well time.strftime('Hour%-I:Min%M:Sec%-S') Output: 'Hour11:Min8:Sec5'
Pythontic
pythontic.com βΊ datetime βΊ date βΊ strftime
The strftime() function in Python | Pythontic.com
The strftime() function of a date instance in Python returns a date string as per the format specified.An example program is given with strftime() output
Esri Community
community.esri.com βΊ t5 βΊ python-questions βΊ milliseconds-with-strftime βΊ td-p βΊ 73258
Solved: Milliseconds with strftime - Esri Community
December 10, 2021 - from datetime import datetime curr_time = datetime.now() formatted_time = curr_time.strftime('%H:%M:%S.%f') print(formatted_time) 18:41:59.891075ββββββββββββββ Β· How to get min, seconds and milliseconds from datetime.now() in Python
Tutorialspoint
tutorialspoint.com βΊ python βΊ time_strftime.htm
Python time strftime() Method
February 17, 2009 - Similar to the Python time asctime() method, the strftime() method also converts a tuple or struct_time representing, either in UTC or the local time, to a 24-character string of the following form: 'Mon Jan 9 10:51:77 2023'. However, the contrast occurs when the strftime() method formats the string output in a user-friendly way.
Programiz
programiz.com βΊ python-programming βΊ datetime βΊ strftime
Python strftime() - datetime to string
Become a certified Python programmer. Try Programiz PRO! ... The strftime() method returns a string representing date and time using date, time or datetime object.
CodinGeek
codingeek.com βΊ home βΊ strftime function in python - python datetime module
Python strftime() - Format Date Time to String | Codingeek
August 8, 2021 - The function or method strftime() is used to get the formatted string output of the provided date, time or DateTime object.
Raspberry Pi
projects.raspberrypi.org βΊ en βΊ projects βΊ generic-python-strftime
Getting the current date or time in Python - Raspberry Pi Projects
We're sorry, but this site requires JavaScript to operate
Strftime
strftime.net
Strftime
By Richard Felix and Chris Coyier. Live preview by Jake Moffatt