You can download this code by clicking the button below.
This code is now available for download.
This function takes a datetime object and returns a string formatted as YYYY-MM-DD HH:MM:SS.
Technology Stack : datetime
Code Type : Function
Code Difficulty : Intermediate
import datetime
def format_date(date_obj):
"""
将datetime对象格式化为字符串。
"""
return date_obj.strftime("%Y-%m-%d %H:%M:%S")