How can I transfer python datetime to discord DateTimeCord?
Question:
hmm… how can I turn a python DateTime obj to discord DateTimeCord (<t: ? :R>)
?
(I can transfer that using this by myself but I want to do this thing with a bot)
I had tried .toordinal()
but that is not correct…
Answers:
The number in the middle is the epoch timestamp of your Datetime
instance.
py_dt = datetime.now() # Whatever your current datetime is
epoch = round(py_dt.timestamp()) # Timestamp returns a float so round it
disc_dt = f"<t:{epoch}:R>"
You could’ve also gotten that from the Discord docs though (last two lines).
hmm… how can I turn a python DateTime obj to discord DateTimeCord (<t: ? :R>)
?
(I can transfer that using this by myself but I want to do this thing with a bot)
I had tried .toordinal()
but that is not correct…
The number in the middle is the epoch timestamp of your Datetime
instance.
py_dt = datetime.now() # Whatever your current datetime is
epoch = round(py_dt.timestamp()) # Timestamp returns a float so round it
disc_dt = f"<t:{epoch}:R>"
You could’ve also gotten that from the Discord docs though (last two lines).