def usetz_now ( ) : USE_TZ = getattr ( settings , 'USE_TZ' , False ) if USE_TZ and DJANGO_VERSION >= '1.4' : return now ( ) else : return datetime . utcnow ( )
time zones in django python
Determine current time depending on USE_TZ setting .
def usetz_now():
    """Determine current time depending on USE_TZ setting.

    Affects Django 1.4 and above only. if `USE_TZ = True`, then returns
    current time according to timezone, else returns current UTC time.

    """
    USE_TZ = getattr(settings, 'USE_TZ', False)
    if USE_TZ and DJANGO_VERSION >= '1.4':
        return now()
    else:
        return datetime.utcnow()