【发布时间】:2013-01-29 03:46:36
【问题描述】:
//This will get the month as an int (e.g. 4)
DateTime dLastMonth = DateTime.Today.AddMonths(-1);
int iLastMonth = dLastMonth.Year;
如何让上面的代码输出01、02等...而不是1、2、3...
【问题讨论】:
-
你试过谷歌吗?
c# datetime format的第一个命中是 msdn.microsoft.com/en-us/library/8kb3ddd4.aspx -
如果要格式化整个日期,为什么只提取年份部分?
-
我想他想如果月份是一月,去掉一个月,会是哪一年...... 胡乱猜测。