MATLAB Answers

Easy question converting numbers to hours

14 views (last 30 days)
Hi all, I know this should be easy, but how would you convert whole numbers into HH:MM format? Like say 1156 into 11:56 ? Thank you

  0 Comments

Sign in to comment.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 1 Sep 2016
Edited: Azzi Abdelmalek on 1 Sep 2016
datestr(datenum(sprintf('%04d',1156),'HHMM') ,'HH:MM')
Or
a=sprintf('%04d',1156)
a=sprintf('%s:%s',a(1:2),a(3:4))

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.