Nebulous
Nebulous

Reputation: 1

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.

Upvotes: 0

Views: 491

Answers (1)

Enviy
Enviy

Reputation: 91

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

This should collect your current epoch time.

Upvotes: 1

Related Questions