You can download this code by clicking the button below.
This code is now available for download.
This function gets the current time and formats it as 'YYYY-MM-DD HH:MM:SS'.
Technology Stack : datetime package, strftime method
Code Type : Function
Code Difficulty : Intermediate
import datetime
def get_current_time():
current_time = datetime.datetime.now()
return current_time.strftime("%Y-%m-%d %H:%M:%S")