zoukankan      html  css  js  c++  java
  • [转] c# 时间操作

    一、取某月的最后一天

    一、取某月的最后一天
    法一、使用算出该月多少天,年
    ++加上多少天即得,举例取今天这个月的最后一天

    private void GetLastDateForMonth(DateTime DtStart,out DateTime DtEnd)
      
    {
       
    int Dtyear,DtMonth;

       DtStart 
    = DateTime.Now;
       Dtyear  
    = DtStart.Year;
       DtMonth 
    = DtStart.Month;

       
    int MonthCount = DateTime.DaysInMonth(Dtyear,DtMonth);
       DtEnd 
    = Convert.ToDateTime(Dtyear.ToString()+"-"+DtMonth.ToString()+"-"+MonthCount);

      }


    法二、取出下月的第一天减去一天便是这个的最后一天

    private void GetLastDateForMonth(DateTime DtStart,out DateTime DtEnd)
      
    {
       
    int Dtyear,DtMonth;

       DtStart 
    = DateTime.Now.AddMonths(1);
       Dtyear  
    = DtStart.Year;
       DtMonth 
    = DtStart.Month;
       
       DtEnd 
    = Convert.ToDateTime(Dtyear.ToString()+"-"+DtMonth.ToString()+"-"+"1").AddDays(-1);

      }




    法一、使用算出该月多少天,年++加上多少天即得,举例取今天这个月的最后一天

    法二、取出下月的第一天减去一天便是这个的最后一天
  • 相关阅读:
    CKeditor3.6.2 配置与精简
    CKEditor与CKFinder整合并实现文件上传功能
    实体关联关系映射:
    status pending状态
    wx:for
    小程序
    获取指定控件的值
    报表
    dataGridView 设置
    SQLite 的使用
  • 原文地址:https://www.cnblogs.com/xiang/p/454957.html
Copyright © 2011-2022 走看看