How to convert 24 hours time to 12 hours ?

27 views
Skip to first unread message

Prashanth Patelc

unread,
Jul 22, 2022, 2:08:05 PM7/22/22
to django...@googlegroups.com
how to use time in pandas  (convert 24 hours time to 12 hours)

Login time  table
==========
userid     logindate              logintime 
2            2022-13-07      18:30:00.490337

Logout time table
==========

userid     logindate              logintime 
2            2022-14-07      02:36:03.450327


output:
   login_date          user__username       user              diiffrences
0  2022-07-14          neil                        neil               -1 days +07:26:47.027887

How to convert above atbles time:  ?

nee output like this type
==============
     login_date          user__username       user              diiffrences
0  2022-07-14          neil                        neil                  08:03:47.027887

  
df['logout_time'] = pd.to_timedelta(df['logout_time'].astype(str))

df['login_time'] = pd.to_timedelta(df['login_time'].astype(str))


df['diiffrences'] = df['logout_time'] - df['login_time']

Mahendra

unread,
Jul 23, 2022, 12:30:37 PM7/23/22
to django...@googlegroups.com
--
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 django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMCU6CpwW9q9z_pBdgf%3Do5dEzvET5qqvddopjNQtGwuxm5RUjA%40mail.gmail.com.

Lakshyaraj Dash

unread,
Jul 23, 2022, 12:40:11 PM7/23/22
to django...@googlegroups.com
You can do something like shown in the screenshot below

Thanks and Regards
Lakshyaraj Dash

IMG_20220723_220730254_HDR.jpg

Lalit Suthar

unread,
Jul 24, 2022, 1:50:13 AM7/24/22
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages