×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python datetime Class Methods

Python datetime class has the following built-in functions.

Method Description
__str__() Returns a string representation of the object.
astimezone() Returns a datetime object with new tzinfo attribute tz.
date() Converts value (datetime) into a date object.
isocalendar() Returns a 3-tuple (ISO year, ISO week number, ISO weekday).
isoformat() Returns a string representing the date and time in ISO 8601 format.
isoweekday() Returns the day of the week as an integer, where Monday is 1 and Sunday is 7.
replace() Replace the date and time with the same value.
strftime() Returns a string representing the date and time, which is controlled by an explicit format string.
time() Converts value (datetime) into a time object.
timetuple() Returns a time.struct_time which is an object with a named tuple interface containing nine elements.
timetz() Return time object with same hour, minute, second, microsecond, and tzinfo attributes.
toordinal() Return the proleptic Gregorian ordinal of the date, where January 1 of year 1 has ordinal 1.
tzname() Returns the time zone name of the datetime object passed, as a string.
utcoffset() Returns a timedelta instance corresponding to UTC offset of the tzinfo specified in the instance given.
weekday() Returns the day of the week as an integer, where Monday is 0 and Sunday is 6.
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.