注册 登录
  • 欢迎访问Sharezer Blog

C#秒转时间timeStampToString

C# sharezer 599次浏览 已收录 0个评论
public static string timeStampToString(int time)
{
    long ltime = (long )time;
    DateTime t = new DateTime(time * TimeSpan.TicksPerSecond);
    t = t. ToLocalTime();
    int year = t.Year + 1969 ;
    string syear = "" + year;
    int month = t.Month ;
    string smonth = month < 10 ? "0" + month : "" + month;
    int day = t.Day;
    string sday = day < 10 ? "0" + day : "" + day;
    int hour = t.Hour;
    string shour = hour < 10 ? "0" + hour : "" + hour;
    int minute = t.Minute ;
    string sminute = minute < 10 ? "0" + minute : "" + minute;
    int second = t.Second ;
    string ssecond = second < 10 ? "0" + second : "" + second;

    return syear + "/" + smonth + "/" + sday + " " + shour + ":" + sminute + ":" + ssecond;
}

Sharezer , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明C#秒转时间timeStampToString
喜欢 (0)
[liangshaoze@sina.cn]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址