near_me
Linear Algebra
keyboard_arrow_down 52 guides
1. Vectors
2. Matrices
3. Linear equations
4. Matrix determinant
5. Vector space
6. Special matrices
7. Eigenvalues and Eigenvectors
8. Orthogonality
9. Matrix decomposition
check_circle
Mark as learned thumb_up
0
thumb_down
0
chat_bubble_outline
0
auto_stories new
settings
Python Datetime | fromtimestamp method
schedule Mar 5, 2023
Last updated local_offer
Tags Python
tocTable of Contents
expand_more Check out the interactive map of data science
Python’s date.fromtimestamp(~)
method converts a Unix timestamp to a date
object.
NOTE
A Unix timestamp is the number of seconds between a particular date and January 1, 1970 UTC.
Parameters
1. timestamp
| Unix timestamp
The Unix timestamp to convert to corresponding date
object.
Return value
A date
object based off the provided Unix timestamp.
Examples
To return date
object from Unix timestamp 1476561252
:
from datetime import date timestamp = date.fromtimestamp(1476561252)print(timestamp)print(type(timestamp))
2016-10-16<class 'datetime.date'>
To return date
object from current Unix timestamp:
import datetimeimport time
timestamp = time.time()print(timestamp)
date_object = date.fromtimestamp(timestamp)print(date_object)
1610854011.178642021-01-17
Published by Arthur Yanagisawa
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
Official Python Documentation
https://docs.python.org/3/library/datetime.html#datetime.date.fromtimestamp
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!