converting from integer time to datetime in 3-hourly data
显示 更早的评论
I've tried everything I can think of to convert from integer time to datetime. Anyone have any intuitions or suggestions? Thanks!
time
Size: 13208x1
Dimensions: record
Datatype: double
Attributes:
standard_name = 'time'
long_name = 'Time'
units = 'hours since 1979-12-01 00'
time_calendar = 'gregorian'
start = '1979120100'
step = '3'
With having a time step of '3' I'm not sure how to apply the datetime function.
For reference:
>> time(1)
ans =
176064
6 个评论
Carrie Merritt
2020-12-1
My answer moved here:
X = {'1979120100', '1979120103', '1979120106'}
T = datetime(X,'InputFormat','yyyyMMddhh','Format','yyyy-MM-dd HH:mm')
result is:
T =
1×3 datetime array
1979-12-01 00:00 1979-12-01 03:00 1979-12-01 06:00
Some calculation:
>> T(3)-T(1)
ans =
duration
06:00:00
Stephan
2020-12-1
Carries comment moved here:
Hi Stephan,
Thanks for the response. If you notice, I referenced the first time integer (e.g., time(1) = 176064). The method you have suggested assumes I already have a time vector in the 'yyyyMMddHH' format. Which I do not. It is what I need though.
I'm not sure what kind of time units I'm working with aside from what information I have in the netCDF file.
Stephan
2020-12-1
I see, can you attach the data object you have there?
Carries comment moved here:
Please see attached. There isn't anything on the script aside from my numerous failed attempts at trying to make this work. All I'm trying to do is read the time in and convert it from its original netCDF format to a date/time format.
Walter Roberson
2020-12-1
Is it possible that the first time should be 05-Jun-1982 ?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
