zoukankan      html  css  js  c++  java
  • 如何取到两个日期中的每一天,并且打印出来

    代码如下

    static void Main(string[] args)
            {
                DateTime one = Convert.ToDateTime("2009-02-01");
                DateTime two = Convert.ToDateTime("2008-12-01");

                for (DateTime dt = two; dt < one; dt = dt.AddDays(1))
                {
                    string year = dt.Year.ToString();
                    string month = dt.Month.ToString();
                    string day = dt.Day.ToString();

                    if (month.Length == 1)
                    {
                        month = "0" + month;
                    }

                    if (day.Length == 1)
                    {
                        day = "0" + day;
                    }

                    string time_M = year + "-" + month + "-" + day;
                    Console.WriteLine(time_M);
                }
                Console.ReadLine();
            }

  • 相关阅读:
    magento 去掉index.php
    TCP三次握手与四次挥手
    <Jper和Iperf>的安装及使用
    【Python】安装方法小结
    【ubuntu】日常网络配置信息的查看及修改
    DNS解析
    【Dig工具】
    【ping/tracert】的简单使用
    【VMvare】yum在线源
    配置文件加载
  • 原文地址:https://www.cnblogs.com/Johnfx-home/p/3146285.html
Copyright © 2011-2022 走看看