秒转换成年月日秒的算法

        public string ShowDateTime(string strSecond)
        {
            string strDate = string.Empty;
           
            if (strSecond != string.Empty)
            {
                if (strSecond == "0")
                {
                    return "在线用户,还没有退出.";
                }
                Int64 intSecond = Convert.ToInt64(strSecond);


                // if(intSecond > 86400)
                strDate = DateFormat(intSecond / 86400) + "天" + DateFormat((intSecond % 86400) / 3600) + "小时" + DateFormat((intSecond % 86400) % 3600 / 60) + "分钟" + DateFormat((intSecond % 86400) % 3600 % 60 % 60) + "秒";


            }
            return strDate;
        }

 

 private string DateFormat(long intNum)
        {
            string str;
            if (intNum > 9)
                str = intNum.ToString();
            else
                str = "0" + intNum.ToString();
            return str;
            //HttpUtility.UrlEncode(
        }

 

 

posted @ 2008-12-02 13:58  chunchill  阅读(996)  评论(0编辑  收藏  举报