first commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
from datetime import datetime, date
|
||||
import pytz
|
||||
|
||||
def get_current_date(date_formate='%Y-%m-%d'):
|
||||
"""
|
||||
获取当前日期字符串,格式化为指定格式,默认格式为'YYYY-MM-DD'
|
||||
"""
|
||||
tz = pytz.timezone('Asia/Shanghai') # 设置为中国时区
|
||||
current_date = datetime.now(tz)
|
||||
return current_date.strftime(date_formate)
|
||||
|
||||
def datetime_date(date: str) -> date:
|
||||
return datetime.strptime(date, "%Y-%m-%d").date()
|
||||
Reference in New Issue
Block a user