Skip to content

Instantly share code, notes, and snippets.

@Suhaib3100
Created December 4, 2024 09:13
Show Gist options
  • Save Suhaib3100/589d197b7917e798bd019c7b4d3ac18a to your computer and use it in GitHub Desktop.
Save Suhaib3100/589d197b7917e798bd019c7b4d3ac18a to your computer and use it in GitHub Desktop.
Timestamps
import time
# Get the current timestamp
current_timestamp = time.time()
print("Current Timestamp (seconds since epoch):", current_timestamp)
@Suhaib3100
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment