日期时间转时间戳:方法、示例及代码
时间戳是指从1970年1月1日00:00:00 UTC(协调世界时)开始经过的秒数。
将日期时间'2023-09-14 00:00:00'转换为时间戳,可以使用编程语言中的日期时间函数或者在线工具。
在Python中,可以使用datetime模块来进行转换:
import datetime
date_string = '2023-09-14 00:00:00'
timestamp = datetime.datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S').timestamp()
print(int(timestamp))
这将输出时间戳:1699510400
在其他编程语言中,也有类似的日期时间处理函数来进行转换。
原文地址: https://www.cveoy.top/t/topic/oyS6 著作权归作者所有。请勿转载和采集!