1周添加到当前的日期 [英] Add 1 week to current date

查看:87
本文介绍了1周添加到当前的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的事情 DateTime.Now.ToString(DD.MM.YY); 在我的代码,我需要1周增加它,就像 2012年4月5日成为 2012年4月12日我试图将其转换为int,然后添加它,但有一个问题,当它是由30个。

I've got something like this DateTime.Now.ToString("dd.MM.yy"); In my code, And I need to add 1 week to it, like 5.4.2012 to become 12.4.2012 I tried to convert it to int and then add it up, but there is a problem when it's up to 30.

你能告诉我一些聪明的方式该怎么办呢?

Can you tell me some clever way how to do it?

推荐答案

您要离开它作​​为一个的DateTime ,直到你准备把它转换为字符串。

You want to leave it as a DateTime until you are ready to convert it to a string.

DateTime.Now.AddDays(7).ToString("dd.MM.yy");

这篇关于1周添加到当前的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆