在ASP.NET C#中的日期格式中添加天数(dd/MM/yyyy) [英] Add Days in Date Formet(dd/MM/yyyy) in asp .net C#

查看:98
本文介绍了在ASP.NET C#中的日期格式中添加天数(dd/MM/yyyy)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何添加编号.日期(dd/MM/yyyy)格式的月份.

How we can add no. of months in date (dd/MM/yyyy) format.

推荐答案

您可以像下面这样尝试:
You can try like bellow:
<asp:boundfield datafield="ModifiedDate" headertext="Modified Date" dataformatstring="{0:dd/MM/yyyy}" xmlns:asp="#unknown" />



谢谢



Thanks,


如果您使用的是DateTime数据类型,则可以使用AddMonths方法.如果您使用字符串来处理日期,

1.不对.
2.将其转换为DateTime,然后添加月份.
If you are using DateTime datatype, you can use AddMonths method. If you are using string to take care of dates,

1. It is not right.
2. Convert it to DateTime and then add months.


DateTime _dt = DateTime.Now.AddMonths(no of months);
string _dateSting = _dt.ToString("dd/MM/yyyy");


这篇关于在ASP.NET C#中的日期格式中添加天数(dd/MM/yyyy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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