You can download this code by clicking the button below.
This code is now available for download.
Converts a datetime object to a readable date and time string.
Technology Stack : datetime, strftime
Code Type : Date formatting
Code Difficulty : Intermediate
import datetime
import json
def format_date(date_obj):
"""
将datetime对象格式化为字符串。
"""
formatted_date = date_obj.strftime('%Y-%m-%d %H:%M:%S')
return formatted_date