Created
December 4, 2024 09:13
-
-
Save Suhaib3100/589d197b7917e798bd019c7b4d3ac18a to your computer and use it in GitHub Desktop.
Timestamps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
# Get the current timestamp | |
current_timestamp = time.time() | |
print("Current Timestamp (seconds since epoch):", current_timestamp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For readable
from datetime import datetime
Example timestamp
example_timestamp = 1701739200 # Example: Dec 4, 2024
Convert timestamp to datetime
converted_datetime = datetime.fromtimestamp(example_timestamp)
print("Readable Date and Time:", converted_datetime)