zoukankan      html  css  js  c++  java
  • C#获取指定日期所在周/月/年的起始时间

    以下内容转自http://www.cnblogs.com/musickh/archive/2009/07/16/1524912.html,在此多谢博主!

    DateTime.Now=2009-7-16 5:20:56

    //今天

    DateTime.Now.Date.ToString(); "2009-7-16 0:00:00"

    //周起始日期

    DateTime.Now.Date.AddDays(-(int)(DateTime.Now.DayOfWeek)+1).ToString(); {2009-7-13 0:00:00} DateTime.Now.Date.AddDays(7-(int)(DateTime.Now.DayOfWeek)).ToString(); {2009-7-19 0:00:00}

    //月起始日期 new DateTime(DateTime.Now.Year,DateTime.Now.Month,1).ToString(); {2009-7-1 0:00:00}

    new   DateTime(DateTime.Now.Date.Year,DateTime.Now.Date.Month,DateTime.DaysInMonth(DateTime.Now.Date.Year,DateTime.Now.Date.Month)).ToString(); "2009-7-31 0:00:00"

    //年起始日期 new   DateTime(DateTime.Now.Date.Year,1,1).ToString(); {2009-1-1 0:00:00} new   DateTime(DateTime.Now.Date.Year,12,DateTime.DaysInMonth(DateTime.Now.Date.Year,DateTime.Now.Date.Month)).ToString(); {2009-12-31 0:00:00}

  • 相关阅读:
    进阶篇:3.1.8)DFM塑胶-注射模具和设备
    PAT-甲级-1001-A+B Format
    腾讯-004-两个排序数组的中位数
    机器学习三 决策树
    腾讯-002-两数相加
    2018.3.15
    2018.3.14
    2018.3.13
    废代码合集
    边缘检测程序(matlab)
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3037617.html
Copyright © 2011-2022 走看看