Syntax error Getting formatted time in Python

Getting formatted time in Python



You can format any time as per your requirement, but simple method to get time in readable format is asctime() −

Example

 Live Demo

#!/usr/bin/python
import time;
localtime = time.asctime( time.localtime(time.time()) )
print "Local current time :", localtime

Output

This would produce the following result −

Local current time : Tue Jan 13 10:17:09 2009
Updated on: 2020-01-28T13:05:46+05:30

491 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements