from datetime import datetime, timezone datetime.now(timezone.utc).strftime("%Y%m%d")
Or as Davidism pointed out, this would also work:
from datetime import datetime datetime.utcnow().strftime("%Y%m%d")
I prefer the first approach, as it gets you in the habit of using timezone aware datetimes - but as J.F. Sebastian pointed out - it requires Python 3.2+. The second approach will work in both 2.7 and 3.2 branches.