Add datetime-python/README.md

This commit is contained in:
2025-01-24 11:16:23 +00:00
parent 26505a37c4
commit 4c569e6be3

15
datetime-python/README.md Normal file
View File

@@ -0,0 +1,15 @@
```python
def Timestamp(dt):
from datetime import datetime
dt_object = datetime.strptime(dt, '%Y-%m-%d %H:%M:%S')
return int(dt_object.timestamp())
def Datetime(timestamp):
from datetime import datetime
dt_object = datetime.fromtimestamp(timestamp)
return str(dt_object)
datetime = '2024-12-16 05:34:37' # SQLite
print(timestamp := Timestamp(datetime)) # 1734294877
print(Datetime(timestamp) == datetime) # True
```