gdjlc

培养良好的习惯,每天一点一滴的进步,终将会有收获。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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

posted on 2009-12-13 21:04  gdjlc  阅读(259)  评论(0编辑  收藏  举报