简体   繁体   English

自2000年1月1日以来的单位秒为日期时间

[英]unit seconds since 2000-01-01 as datetime

The time variable of my dataset has the unit 's since 2000-01-01', type numpy.float64. 我的数据集的时间变量自2000年1月1日以来的单位为,键入numpy.float64。 For example time[0] = 591667567.96861005 How can I converte this into a date string of this format: '2018-10-31T06:50:33'? 例如,time [0] = 591667567.96861005如何将其转换为以下格式的日期字符串:'2018-10-31T06:50:33'?

Use a base date and timedelta with your seconds since 2000-01-01 . 使用基准日timedelta你秒自2000-01-01

In [1]: from datetime import datetime, timedelta                                                                                                                                                                                                              

In [2]: base_date = datetime(2000, 1, 1)                                                                                                                                                                                                                      

In [3]: d = base_date + timedelta(seconds=591667567.96861005)                                                                                                                                                                                                     
Out[3]: datetime.datetime(2018, 10, 1, 0, 6, 7, 968610)

In [5]: d.strftime("%Y-%m-%d %H:%M:%S")                                                                                                                                                                                                                       
Out[5]: '2018-10-01 00:06:07'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python - 将格式为“2000-01-01”的字符串日期列表转换为格式为 YYYYmmdd 的浮点日期列表 - Python - Convert list of string dates in format '2000-01-01' to list of float dates in format YYYYmmdd 如何使用 Python 代码生成诸如“2000-01-01”、“2000-02-01”、....“2011-12-01”之类的日期范围 - How can I generate date range like '2000-01-01', '2000-02-01',....'2011-12-01' using Python code 如何创建一个从“2000-01-01”开始到 10 个周末(星期六)的时间序列,然后以随机数作为值。(在 Python 中)? - How to create a timeseries starting "2000-01-01" and 10 weekends(saturdays) after that having random numbers as values.(in Python)? 将自纪元以来的秒转换为自0001-01-01 UTC以来的天数 - Convert seconds since epoch to days since 0001-01-01 UTC in Python 自 1970 年 1 月 1 日以来经过了多少秒,包括闰秒? - How many seconds elapsed since 01/01/1970, leap-seconds included? 检查日期是否不等于NA或字符串,并且date &lt;datetime(2000,01,01)用Python中的熊猫数据框中的NaT替换日期 - check if date is not equal to NA or string and date< datetime(2000,01,01) replace date with NaT in pandas Dataframe in Python datetime index KeyError:&#39;标签[2000-01-03 00:00:00]不在[index]中 - datetime index KeyError: 'the label [2000-01-03 00:00:00] is not in the [index]' 格式01-01-16 7:43字符串为日期时间 - format 01-01-16 7:43 string to datetime Python日期时间1970-01-01 07:00:07 - Python Datetime 1970-01-01 07:00:07 转换为日期时间,但如何在 python 中删除“1900-01-01” - Convert to datetime, but how to drop '1900-01-01' in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM