如何将十进制数转换为时间,反之亦然

6 c#

这是一个例子

            if 8.30 is there it should be 8 hours 30 minute
            if 8 hour 20 minutes  then 8.20  

           Please tell whether it is possible ? if yes
           how ?      
Run Code Online (Sandbox Code Playgroud)

Eri*_* J. 11

当人们谈论小时时,他们通常意味着0.1 = 6分钟.

因此,转换8.3的正确公式将是:

8小时+ 3*6分钟= 8:18

要将8:20转换为十进制,它将是:

8 + 20/6 = 8.333333(可能是8.3)

  • 是的,但这个问题很可能错误地说明了实际要求.从十进制小时到分钟没有逻辑映射,包括:20 = .2和:30 = .3.我的回答反映了可能性. (7认同)