Maybe this will help, check out this code. def login (): login_time = time.time() def logout (): logout_time = time.time() #To get the number of seconds the user spent on the platform, #subtract login_time from logout_time
On Monday, July 31, 2023 at 6:12:23 PM UTC+8 Prashanth Patelc wrote: > Thank you all. > > Thank you # madhusudan (I got on idea through you shared the code) > > On Fri, Jul 28, 2023, 8:16 PM Madhusudhan Reddy <[email protected]> > wrote: > >> To get Logout time based on login time, >> >> login time = some thing >> >> logout time = login time + 8 hours >> >> use datetime timedelta module in python, >> >> >>> CODE <<< >> from datetime import datetime, timedelta >> login_time = datetime.now() >> logout_time = login_time + timedelta(hours=8) >> >>> CODE <<< >> >> >> >> >> >> >> >> >> >> On Fri, 28 Jul 2023 at 20:05, Prashanth Patelc <[email protected]> >> wrote: >> >>> Hi all, >>> >>> How to get logout time based on login time in python? >>> >>> I'm storing hour in one column >>> Eg ; hour >>> 8 >>> Based on 8 Calculate logout time >>> >>> My login time 10:00:00 >>> >>> I need 6: 00:00 (based 8) >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/CAMCU6Cpe32Pcs5PAmbx8LDcJzqqPwuhJVzrz%2B%3D67-tEMBychOw%40mail.gmail.com >>> >>> <https://groups.google.com/d/msgid/django-users/CAMCU6Cpe32Pcs5PAmbx8LDcJzqqPwuhJVzrz%2B%3D67-tEMBychOw%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> Best regards, >> Madhusudhan >> +91 90007 79457 <+91%2090007%2079457> >> Gmail | LinkedIn <https://www.linkedin.com/in/msreddygone/> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAFwQctLwNxagOX-QKVUdp58gk4px0M_qftqU3rnHayGaJ9BjAw%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/django-users/CAFwQctLwNxagOX-QKVUdp58gk4px0M_qftqU3rnHayGaJ9BjAw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c727f577-f89c-4a28-bef9-072093667f41n%40googlegroups.com.

