转自: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);
    }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2022-02-07
  • 2022-12-23
  • 2021-09-01
  • 2022-12-23
猜你喜欢
  • 2021-06-01
  • 2021-10-24
  • 2021-12-07
  • 2022-02-11
  • 2022-12-23
  • 2021-07-29
相关资源
相似解决方案