Converting decimal hours to hours minutes and seconds

﹥>﹥吖頭↗ 提交于 2019-12-05 13:03:59

How about this ...

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<xsl:variable name="decimal_hours" select="3.14"/>

<xsl:template match="/">
<xsl:value-of select="concat(
  format-number(floor($decimal_hours              ), '00:'),
  format-number(floor($decimal_hours *  60 mod  60), '00:'),
  format-number(floor($decimal_hours * 360 mod 360), '00'))"/>
</xsl:template>

</xsl:stylesheet>

Just in case anyone had the issue I just had which the above answer was brilliant, but I needed to take Decimal MINUTES into hours:minutes:seconds. so below is the breakdown to help with that if required, a little cut back...

<xsl:value-of select="concat(
  format-number(floor($Decimal_Minutes div 60), '00:'),
  format-number(floor($Decimal_Minutes mod 60), '00:'),
  format-number(($Decimal_Minutes - floor($Decimal_Minutes)) * 60, '00'))"/>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!