zoukankan      html  css  js  c++  java
  • C#时间差

     1      #region 获取时间差
     2         /// <summary>
     3         /// 获取时间差
     4         /// </summary>
     5         /// <param name="t">实际时间</param>
     6         /// <returns>时间差</returns>
     7         public static string GetDiffTime(DateTime t)
     8         {
     9             var time = DateTime.Now - t;
    10             if (time.TotalDays > 30)
    11             {
    12                 var currentMonth = Math.Floor(time.TotalDays / 30);
    13                 if (currentMonth >= 12)
    14                 {
    15                     return "1年前";
    16                 }
    17                 return currentMonth + "个月前";
    18             }
    19             if (time.TotalHours > 24)
    20             {
    21                 return Math.Floor(time.TotalDays) + "天前";
    22             }
    23             if (time.TotalHours > 1)
    24             {
    25                 return Math.Floor(time.TotalHours) + "小时前";
    26             }
    27             if (time.TotalMinutes > 1)
    28             {
    29                 return Math.Floor(time.TotalMinutes) + "分钟前";
    30             }
    31             return Math.Floor(time.TotalSeconds) + "秒前";
    32         }
    33 
    34         #endregion
  • 相关阅读:
    Ext.grid.行相关
    FORM 布局
    rs.open sql,conn,1,1全接触
    arguments.callee
    Ext.window.MessageBox xtype: messagebox ; Ext.Msg Ext.MessageBox
    Ext.grid.column
    sql
    正则
    转JS
    quickFilters
  • 原文地址:https://www.cnblogs.com/gaobing/p/13812703.html
Copyright © 2011-2022 走看看