How to convert from matlab time to reall time and date

3 次查看(过去 30 天)
I have
datestr(7.3684e+05)
ans =
'25-May-2017'
But I need the time and seconds aswell, How do I get this ?
whith this information - I am trying to combine this with [x y]=ginput, as I want to take the times off a graph.
I have tried using
datetick('x', 'dd/mm - HH:MM', 'keepticks', 'keeplimits'); and datetick('x')
Any advise would be appreciated as I am not following the help pages for this problem

采纳的回答

Stephan
Stephan 2018-11-26
编辑:Stephan 2018-11-26
datestr(7.3684e+05,'dd-mmmm-yyyy HH:MM:SS')
ans =
'25-May-2017 00:00:00'
or with some content in it:
>> datestr(7.3684e+05+13.42,'dd-mmmm-yyyy HH:MM:SS')
ans =
'07-June-2017 10:04:48'
Best regards
Stephan
  4 个评论
Rebecca Ellis
Rebecca Ellis 2018-11-26
I am getting :
'15-Oct-4034 01:40:08'
'15-Oct-4034 13:40:38'
'15-Oct-4034 01:59:33'
'15-Oct-4034 13:47:54'
But they should be all 23rd/24th of may 2017
When I follow:
% t1 = datetime('23-May-2017 09:15:00');
%change format to :
t1 = datetime('2017-05-23 09:15:00');
% Get 5 Points
[x,y] = ginput(4);
% Calculate the picked dates with time
date_x = x(:)+t1;
Rebecca Ellis
Rebecca Ellis 2018-11-26
time = datestr(x)
time =
4×20 char array
'23-May-2017 16:25:08'
'24-May-2017 04:25:38'
'23-May-2017 16:44:33'
'24-May-2017 04:32:54'
And it seemed to have worked, thank you for helping me get to here. much appreciated.

请先登录,再进行评论。

更多回答(1 个)

Peter Perkins
Peter Perkins 2018-11-27
Rebecca, your description is not clear enough to understand what you are trying to do, but unless you are using a fairly old version of MATLAB, you should try to stay away from the old datenum/datestr functions and use datetime instead.

类别

Help CenterFile Exchange 中查找有关 Time Series Objects 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by