asp.net int 总秒数 获取时间戳

测试成功

[Test]
        public TimeSpan geTimeSpan(int val)
        {
            var result = new TimeSpan();
            if (val < 60)
            {
                var query = new TimeSpan(0, 0, val);

                result = query;
            }
            if (val < 3600)
            {
                var m = val/60;
                var s = val%60;
                var query = new TimeSpan(0,m,s);

                result = query;
            }
            else
            {
                var h = val/3600;
                var m = val / 60;
                var s = val % 60;
                var query = new TimeSpan(h, m, s);

                result = query;
            }
            return result;
        }



posted @ 2015-01-29 23:03  游子善心  阅读(1)  评论(0编辑  收藏  举报  来源