Get Current Timestamp Using Python Last Updated : 05 May, 2025 Comments Improve Suggest changes Like Article Like Report A timestamp is a sequence of characters that represents the date and time at which a particular event occurred, often accurate to fractions of a second. Timestamps are essential in logging events, tracking files, and handling date-time data in various applications. There are 3 different ways to get the current timestamp in Python, let's explore these methods.Using the time ModuleThe time module provides the time() function, which returns the current time in seconds since the Unix epoch. python import time ts = time.time() print(ts) Output1746164675.3231642 Explanation: time.time() returns the current time as a floating-point number, where the integer part is the seconds and the decimal part represents fractions of a second.Using the datetime ModuleThe datetime module provides the now() function to get the current date and time, and the timestamp() method converts it to a timestamp. python import datetime; ct = datetime.datetime.now() print("current time:", ct) ts = ct.timestamp() print("timestamp:", ts) Outputcurrent time: 2025-05-02 05:44:35.538966 timestamp: 1746164675.538966 Explanation:datetime.datetime.now() gives the current date and time..timestamp() converts this to the timestamp (seconds since the epoch).Using the calendar ModuleThe calendar module can be used along with time.gmtime() to get the current GMT (Greenwich Mean Time), which can then be converted to a timestamp using calendar.timegm(). python import calendar; import time; gmt = time.gmtime() print("gmt:", gmt) ts = calendar.timegm(gmt) print("timestamp:", ts) Outputgmt: time.struct_time(tm_year=2025, tm_mon=5, tm_mday=2, tm_hour=5, tm_min=44, tm_sec=35, tm_wday=4, tm_yday=122, tm_isdst=0) timestamp: 1746164675 Explanation:time.gmtime() gets the current time in GMT as a tuple.calendar.timegm() converts this tuple into a timestamp (seconds since the epoch).Output prints the current GMT time and its corresponding timestamp. Comment More infoAdvertise with us Next Article Get Current Timestamp Using Python ashishguru9803 Follow Improve Article Tags : Python Python Pandas-Timestamp Practice Tags : python Similar Reads Get current date using Python Prerequisite: DateTime moduleIn Python, Date and Time are not data types of their own, but a module named DateTime can be imported to work with the date as well as time. Datetime module comes built into Python, so there is no need to install it externally. The DateTime module provides some functions 3 min read How to Get Current Date and Time using Python In this article, we will cover different methods for getting data and time using the DateTime module and time module in Python.Different ways to get Current Date and Time using PythonCurrent time using DateTime objectGet time using the time moduleGet Current Date and Time Using the Datetime ModuleIn 6 min read Get current time in milliseconds using Python In this article, we will get the time in milliseconds using Python. Here, we are using two inbuild modules of Python that is Datetime module and the Time Module to get the time in milliseconds. Get time in milliseconds using the DateTime module To get the time in milliseconds we used the DateTime mo 1 min read Get UTC timestamp in Python UTC timestamp represents a specific point in time as measured from the "Unix epoch" â January 1, 1970, 00:00:00 UTC. This timestamp is often used in computing because it is not affected by time zones or daylight saving time, providing a consistent reference time across the globe. When working with t 3 min read Python | Pandas Timestamp.tzinfo Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Timestamp.tzinfo attribute is used to check the timezone of the given Timestamp 2 min read Python | Pandas Timestamp.hour Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Timestamp.hour attribute return the value of the hour for the given Timestamp o 2 min read Convert Datetime to UTC Timestamp in Python Dealing with datetime objects and timestamps is a common task in programming, especially when working with time-sensitive data. When working with different time zones, it's often necessary to convert a datetime object to a UTC timestamp. In Python, there are multiple ways to achieve this. In this ar 3 min read Python | Pandas Timestamp.microsecond Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Timestamp.microsecond attribute return the value of microsecond in the given Ti 2 min read Pandas - Generating ranges of timestamps using Python A timestamp is a string of characters or encrypted or encoded data that identifies the time and date of an event, usually indicating the time and date of day, and is often accurate to a fraction of a second. timestamps are used to maintain track of information. When information was created, transmit 3 min read How to insert current_timestamp into Postgres via Python? For processing timestamps, PostgreSQL supports two data types timestamp and timestamptz. timestamp datatype helps us create a timestamp without timezone, and timestamptz helps us create a timestamp with a timezone. One may store both date and time with the timestamp datatype. It does not, however, i 2 min read Like