zoukankan      html  css  js  c++  java
  • c#日期相关代码

    //当年开始日期、结束日期
    DateTime currentDate = DateTime.Now.Date;
    DateTime yearStart = DateTime.Parse($"{currentDate.Year}-1-1");//开始日期

    DateTime yearEnd = yearStart.AddYears(1).AddDays(-1).AddSeconds(-1);

    int monthdays = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(currentDate.Year, 12);//月天数


    //当月开始日期、结束日期
    DateTime monthStart = currentDate.AddDays(1 - currentDate.Day).Date;
    DateTime monthEnd = currentDate.AddDays(1 - currentDate.Day).Date.AddMonths(1).AddSeconds(-1);
    //上个月开始日期、结束日期

    DateTime lastMonthStart = currentDate.AddMonths(-1).Date.AddDays(1 - currentDate.Day);
    DateTime lastMonthEnd = DateTime.Parse(currentDate.AddDays(1 - currentDate.Day).ToShortDateString()).AddSeconds(-1);

  • 相关阅读:
    Oracle配置手册
    Vim配置手册
    高斯消元
    dp专场的蒟蒻题解
    mac 软件意外退出
    spring security整体流程
    服务启动shell脚本
    nohup 启动命令
    linux service脚本
    docker 安装prometheus和grafna
  • 原文地址:https://www.cnblogs.com/cyqdeshenluo/p/14805486.html
Copyright © 2011-2022 走看看