zoukankan      html  css  js  c++  java
  • C#秒转换为时分秒(转)

    C#将秒数转化为时分秒格式00:00:00
    //将秒数转化为时分秒
    private string sec_to_hms(long duration)
    {
    TimeSpan ts = new TimeSpan(0, 0, Convert.ToInt32(duration));
    string str = "";
    if (ts.Hours > 0)
    {
    str = String.Format("{0:00}", ts.Hours)+":"+ String.Format("{0:00}", ts.Minutes) + ":" + String.Format("{0:00}", ts.Seconds);
    }
    if (ts.Hours == 0 && ts.Minutes > 0)
    {
    str = "00:"+ String.Format("{0:00}", ts.Minutes)+":" + String.Format("{0:00}", ts.Seconds);
    }
    if (ts.Hours == 0 && ts.Minutes == 0)
    {
    str = "00:00:" + String.Format("{0:00}",ts.Seconds);
    }
    return str;
    }
    结果为:

    00:00:10

    00:01:10

    03:01:10等
    https://blog.csdn.net/qq_16687863/article/details/101035803

    ================================================================

    private string GetHMSTime(float time)
    {
    float h = Mathf.FloorToInt(time / 3600f);
    float m = Mathf.FloorToInt(time / 60f - h * 60f);
    float s = Mathf.FloorToInt(time - m * 60f - h * 3600f);
    return h.ToString("00") + ":" + m.ToString("00") + ":" + s.ToString("00");
    }
    https://blog.csdn.net/RocketJ/article/details/113503161

  • 相关阅读:
    坚持博客
    虚拟机CentOS7.2 1611 Minimal最小化安装后桥接固定ip
    Js 希望某链接只能点击一次
    ThinkPHP3.2 杂记
    Mysql 杂记
    Linux挂载Win共享文件夹 一
    Linux 监测系统资源
    Phpstrom 书签应用
    php默认有最大执行时间
    tp3.2中配置链接多个数据库
  • 原文地址:https://www.cnblogs.com/xihong2014/p/15659796.html
Copyright © 2011-2022 走看看