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);
        }

  • 相关阅读:
    cogs 826. Feb11] GF打dota
    cogs 133. [USACO Mar08] 牛跑步 A*k短路算法
    luogu cogs 1437. [NOIP2013]转圈游戏
    RESTful
    中间件
    回顾基础知识,类,fbv,cbv
    Vue
    ES6的一些说明
    小试牛刀2
    小试牛刀
  • 原文地址:https://www.cnblogs.com/gdjlc/p/2086933.html
Copyright © 2011-2022 走看看