Met*_*uru 5 .net c# asp.net datetime
我需要设置结算周期和处理付款.因此,例如,我将立即处理付款,然后将下一个付款设置为从那时起一个月.
所以,如果我得到DateTime.Now有没有快速的方法只添加一个月?一年怎么样?或者我需要将其解析为MM,YYYY,DD,然后添加到MM,如果MM == 12增量年份等等,然后将它重新组合在一起,以便我的字符串提交给这个paypal插件?
这是所需的最终格式:
"YYYY-MM-DDTHH:MM:SS.MSZ".
This is explained in more detail below:
YYYY Four-digit year, e.g. "2005"
MM Two-digit month.
DD Two-digit day.
T Indicates time follows the date.
HH Hours in military time (24-hour format).
MM Minutes
SS Seconds
MS Milliseconds
Z 1-character (US military) representation of the time zone, "A" - "M" are negative offsets -1 to -12, with "J" not being used. "N" - "Y" are positive offsets 1 to 12, and "Z" indicates GMT/UTC (no offset).
For instance, "2004-05-26T15:00:00.00Z" is May 26th, 2004 at 3:00pm GMT.
Run Code Online (Sandbox Code Playgroud)
所以基本上我想知道是否有任何简单的内置方法可以将一个月或一年添加到日期而无需将其作为字符串解析出来.
Mat*_*nes 19
试试这个:
DateTime myDateTime = DateTime.Now.AddMonths(1);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5915 次 |
| 最近记录: |