zoukankan      html  css  js  c++  java
  • 离最近发表时间代码

    转自:http://www.cnblogs.com/zengxiangzhan/archive/2009/10/30/1592926.html

    <% # GetOutTime(Eval( " 发布时间 " ))  %>
     
        
        
    ///   <summary>
        
    /// 离最近发表时间代码
        
    ///   </summary>
        
    ///   <param name="dtime"> 发布时间 </param>
        
    ///   <returns></returns>
         public   static   string  GetOutTime(DateTime dtime)
        {
            DateTime dt 
    =  DateTime.Now;
            TimeSpan ts 
    =  ((TimeSpan)(dt  -  dtime));
            
            
    int  days  =  ts.Days;
            
    int  hours  =  ts.Hours;
            
    int  minutes  =  ts.Minutes;
            
    int  milliseconds  =  ts.Milliseconds;

            
    if  (days  >   0 return   string .Format( " 发布于{0}天前 " , days);
            
    if  (hours  >   0 return   string .Format( " 发布于{0}小时前 " , hours);
            
    if  (minutes  >   0 return   string .Format( " 发布于{0}分钟前 " , minutes);
            
    return   string .Format( " 发布于{0}秒前 " , milliseconds);
        }

  • 相关阅读:
    Python time gmtime()方法
    背包DP整理
    hdu 1561 The more, The Better
    Eclipse无法打开提示could not open jvm.cfg错误
    Http协议
    反射类
    xml——dom&sax解析、DTD&schema约束
    XML、DTD约束
    java——final、权限修饰符
    java——接口、多态性、对象转型
  • 原文地址:https://www.cnblogs.com/gdjlc/p/2086933.html
Copyright © 2011-2022 走看看