Convert time from 24 hours format to HH:MM

I am trying to convert time in the 24 hour format to HH:MM. I require this to write with the title in a figure. For example, time now reads as 12.5 and i need to write this as 12:30. can somebody help me?

 Risposta accettata

sprintf('%02d:%02d', floor(T), floor(60 * mod(T,1)) )

2 Commenti

Thanks a lot..it worked!!!!
It has problems with leap seconds.

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by