C#窗体显示留言时间的方法

2021-07-23 18:03

阅读:508

namespace test

{

class Program

{

static void Main(string[] args)

{

DateTime now = DateTime.Now;

DateTime time = Convert.ToDateTime( “2014-03-17 11:02:00”);

TimeSpan ts = now – time;

if (time.Year == now.Year)

{

if (ts.Days

{

if (ts.Hours

{

if (ts.Minutes

{

string s=ts.Seconds.ToString() + “秒前爱我别走给您留言”;

Console.WriteLine(s);

Console.ReadLine();

return;

}

string a = ts.Minutes.ToString() + “分钟前爱我别走给您留言”;

Console.WriteLine(a);

Console.ReadLine();

return;

}

string b = “今天 ” + time.ToString(“HH:mm”) + “爱我别走给您留言”;

Console.WriteLine(b);

Console.ReadLine();

return;

}

Console.WriteLine(time.Month.ToString()+”月” + time.Day.ToString() +”日”+ time.Hour.ToString(“#00″)+”小时” + time.Minute.ToString(“#00″)+”分钟前”+”爱你的他给你留言了”);

}

Console.ReadLine();

}

}

}


评论


亲,登录后才可以留言!