fromtimestamp() Function Of Datetime.date Class In Python
The fromtimestamp() function is used to return the date corresponding to a specified timestamp.
Note: Here the timestamp is ranging from the year 1970 to the year 2038, and this function does not consider leap seconds if any present in the timestamp. This function is a class method.
Syntax: @classmethod fromtimestamp(timestamp)
Parameters: This function accepts a parameter which is illustrated below:
- timestamp: This is the specified timestamp for which the date is going to be returned.
Return values: This function returns the date corresponding to a specified timestamp.
Example 1: Getting a date corresponding to an Epoch & Unix Timestamp.
1627279008.95 Date for the Timestamp is: 2021-07-26
Example 2: Getting a date corresponding to a specified timestamp.
Date for the Timestamp is: 2011-12-09
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course