Day 089 - Project 89 : Community Chat App

In the solution video, the timestamps are very weird and confusing,

date = datetime.datetime.now()
timestamp = datetime.datetime.timestamp(date)

printing timestamp gives some weird number like 1707674735.861512.

Altering it like :

timestamp = datetime.datetime.now()
timestamp = str(timestamp)
timestamp = timestamp[0:19]

gives a much more understandable timestamp down to the second.

image

I also went ahead and used my time zone specifically.
import pytz

timestamp = datetime.datetime.now(pytz.UTC)
est_tz = pytz.timezone('EST')
now_est = timestamp.astimezone(est_tz)
timestamp = str(now_est)
timestamp = timestamp[0:19]
1 Like