How to Solve NameError: name 'timezone' is not defined -- datetime

Solution: Import the 'timezone' module

# Add the following line to the top of your code
from datetime import timezone

 

For more information:
datetime timezone