首页 > 解决方案 > Get epoch time and replace old value

问题描述

I have a Python script which connects to discord for a 'custom' rich presence. Every time I want to use it, I have to edit the script to enter in the current Epoch time so the counter on Discord starts from when I run the script. I was wondering if there was a way to automate this, having the script get the current time value and replace the old value which was there on run. May not be possible.

标签: pythondiscord

解决方案


from datetime import datetime
now = datetime.utcnow()
epoch_time = int((now - datetime(1970, 1, 1)).total_seconds())

这应该收集您当前的纪元时间。


推荐阅读