当前位置: 代码迷 >> ASP.NET >> 小弟我现在已经写好了函数
  详细解决方案

小弟我现在已经写好了函数

热度:5135   发布时间:2013-02-25 00:00:00.0
我现在已经写好了函数,
想定义一个参数是获取当前时间,另一个参数是获取数据库里面发表文章的时间,当发表文章的时间在5天之内的话,就把发表时间的字体改为红色。。。
改怎样写呢? 我现在已经获取到了发表文章的时间。。。

------解决方案--------------------------------------------------------
探讨

string strdate =DateTime.Parse(date).ToString("yyyy-MM-dd");
//string nowdate=DateTime.Parse(DateTime.Now.ToShortDateString());
DateTime nowdate=DateTime.Now.ToShortDateString();//出错,没法转换成string类型……

------解决方案--------------------------------------------------------
DateTime t1 = DateTime.Parse("2012-01-01");
DateTime t2 = DateTime.Now;
System.TimeSpan ts = t2 - t1;
int days = ts.Days;

if(days<5)
{

//你的操作
}
  相关解决方案