• .net 获取两个时间段中间的日期


    private void GetDataTimeInterval(DateTime begin_time, DateTime end_time, ref List<string> list)
          {
               list.Add(begin_time.ToShortDateString());
               if (begin_time.ToShortDateString() != end_time.ToShortDateString())
               {
                begin_time = begin_time.AddDays(1);
                GetDataTimeInterval(begin_time, end_time, ref list);//返回时间区间列表GetDataTimeInterval

    }
    }

    调用:

    List<string> list = new List<string>();
    GetDataTimeInterval(Convert.ToDateTime(begin_date), Convert.ToDateTime(end_date), ref list);

    此时返回的list就是两个日期中间的

    比如GetDataTimeInterval(2019-07-01,2019-0704), ref list);

    返回的list包含:2019-07-01,2019-07-02,2019-07-03,2019-07-4

  • 相关阅读:
    UVA10361
    △UVA10494
    △UVA465
    △UVA10106
    △UVA424
    阶乘的精确值
    小学生算术
    UVA156
    △UVA120
    linux应用之ntpdate命令联网同步时间
  • 原文地址:https://www.cnblogs.com/ljh19/p/11131378.html
Copyright © 2020-2023  润新知