2021-03-12 10:21:43 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Python script to Process DateTime
|
2021-03-12 11:04:05 -05:00
|
|
|
# Author - HoneyMoose
|
2021-03-12 10:21:43 -05:00
|
|
|
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
json_filename = 'resources/black_rock_test.json'
|
|
|
|
|
2021-03-12 11:04:05 -05:00
|
|
|
today = datetime.date.today()
|
|
|
|
print("Today's date:", today)
|
2021-03-12 10:21:43 -05:00
|
|
|
|
2021-03-12 11:04:05 -05:00
|
|
|
# 从字符串创建日期对象
|
|
|
|
date_user = datetime.datetime.strptime('1/1/2021', '%m/%d/%Y')
|
|
|
|
print("格式化后的日期对象:", date_user)
|
2021-03-12 10:21:43 -05:00
|
|
|
|
2021-03-12 11:04:05 -05:00
|
|
|
# 日期对象通过对格式化输出
|
|
|
|
print("日期对象格式化输出 1 =", today.strftime("%d/%m/%Y"))
|
|
|
|
print("日期对象格式化输出 2 =", today.strftime("%B %d, %Y"))
|
|
|
|
print("日期对象格式化输出 3 =", today.strftime("%m/%d/%y"))
|
|
|
|
print("日期对象格式化输出 4 =", today.strftime("%b-%d-%Y"))
|
2021-03-12 10:21:43 -05:00
|
|
|
|
2021-03-12 11:04:05 -05:00
|
|
|
# 当前时间戳
|
|
|
|
now = datetime.datetime.now()
|
|
|
|
print("当前时间戳:", now)
|