How to convert decimal to time?

53 次查看(过去 30 天)
eg: 7.6 (7+0.6*60) = 7:36

采纳的回答

per isakson
per isakson 2017-10-10
编辑:per isakson 2017-10-10
datestr takes days as input. Thus, divide by 24.
>> val = 7.6;
>> datestr( val/24, 'HH:MM' )
ans =
07:36
I guessed that seven is hours, not minutes.

更多回答(1 个)

Peter Perkins
Peter Perkins 2017-10-13
编辑:Peter Perkins 2017-10-13
This depends on what you mean by "time". Likely, the most useful thing is a duration:
>> t = hours(7.6)
t =
duration
7.6 hr
>> t.Format = 'hh:mm:ss'
t =
duration
07:36:00

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by