localtime() function in python by R4R Team

- localtime() is a python function which return the time of local machine.
- It is defined inside the 'time' library

Syntax-

time.localtime()

-It return localtime in list format that contain day month year, current time etc.


program-

import time
t=time.localtime()

print("Current year is -",t[0])
print("Month is -",t[1])
print("Date is -",t[2])
print("Time is -",t[3],":",t[4],":",t[5])
print(t)


output-

Current year is - 2019
Month is - 5
Date is - 3
Time is - 6 : 44 : 11
time.struct_time(tm_year=2019, tm_mon=5, tm_mday=3, tm_hour=6, tm_min=44, tm_sec=11, tm_wday=4, tm_yday=123, tm_isdst=0)


-In this program, firstly we import the time library by import time then using t=time.localtime() we get all information of local time in the list, then we shows the list items one by one.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!