110,566
社区成员
发帖
与我相关
我的任务
分享
public IList<DateTime> GetTimes(DateTime start, DateTime end)
{
IList<DateTime> times = new List<DateTime>();
while (start <= end)
{
times.Add(end);
start.AddDays(1);
}
return times;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication29
{
class Program
{
static void Main(string[] args)
{
Console.Write( GetTimes(Convert.ToDateTime("2013-04-24 20:00:00"), DateTime.Now));
}
public static string GetTimes(DateTime startTime,DateTime endTime)
{
TimeSpan ts1 = new TimeSpan(startTime.Ticks);
TimeSpan ts2 = new TimeSpan(endTime.Ticks);
TimeSpan ts = ts1.Subtract(ts2).Duration(); //显示时间
return ts.Days.ToString() + "天" + ts.Hours.ToString() + "小时" + ts.Minutes.ToString() + "分钟" + ts.Seconds.ToString() + "秒";
}
}
}