Skip to content

Instantly share code, notes, and snippets.

@sligodave
Created September 28, 2012 15:54
Show Gist options
  • Save sligodave/3800648 to your computer and use it in GitHub Desktop.
Save sligodave/3800648 to your computer and use it in GitHub Desktop.
Get all logins since 2pm pacific time based on internal saved time of central.
import datetime
# Time is Central!
d = datetime.datetime(2012, 9, 26, 14, 00)
# So we can convert our times to Pacific time
dt = datetime.timedelta(hours=2)
from django.contrib.auth.models import User
# Users who have logged in since that time
ut = User.objects.filter(last_login__gte=d).order_by('last_login').values_list('username', 'last_login')
for u, t in ut:
t = (t-td).isoformat()
t = t[t.find('T') + 1:]
t = t[:t.find('.')]
print t, u1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment