如何获得具有完整月份名称的完整日期,如2015年11月2日 [英] How to get full date with full month name like 02 November 2015

查看:61
本文介绍了如何获得具有完整月份名称的完整日期,如2015年11月2日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将日期加载到带有完整月份的文本框中,这意味着用户每次要在文本框中保存日期时都将获得当前日期和时间.他们什么都不会写

I want to load date to the text box with full month, this means that the users will get the current date and time every time they want to save the date on the text box. They won't write anything

以下是我想要的格式:" 2015年11月2日",但没有得到所需的内容.我得到的结果是"DD-NOV-2015",这不是我们想要的.

Here is the format i want "02 November 2015" but am not getting what am looking for. I got this results "DD-NOV-2015" and that's not what am looking for.

您是否知道我可以使用j查询,ajax或任何其他简单方法,请帮助

Should you know any simple way i can do it using j query,ajax or any,please help

请在下面查看我的代码

页面加载

    protected void Page_Load(object sender, EventArgs e)
    {
        this.txtInceptiondate.Text = DateTime.Now.ToString("DD-MMM-yyyy",System.Globalization.CultureInfo.InvariantCulture).ToUpper();
    }

保存到数据库

    protected void tbnSave_Click(object sender, EventArgs e)
    {
        IList<tblPolicy> _Inception = _dc.tblPolicies.Where(a => a.Name == txtname.Text.ToString()).ToList();

        if (_Inception != null)
        {
            if (_Inception.Count() == 0)
            {
                tblPolicy _Policy = new tblPolicy
                {
                    Name = txtname.Text,
                    PolicyName = txtpolicyname.Text,
                    InceptionDate = txtInceptiondate.Text
                };
                _dc.tblPolicies.InsertOnSubmit(_Policy);
                _dc.SubmitChanges();
                lblresults.Visible = true;
                lblresults.Text = "Welcome " + txtname.Text + " ! , Your new policy " + txtpolicyname.Text + " is well recived!";

                txtpolicyname.Text = "";
                txtname.Text = "";
                txtInceptiondate.Text = "";
            }
        }

    }

推荐答案

没有DD作为自定义日期和时间说明符.这些说明符区分大小写.这就是为什么它可以直接反映结果.

There is no DD as a custom date and time specifier. These specifiers are case sensitive. That's why it reflects itself to the result as it is.

您需要改用dd MMMM yyyy格式.并且不要使用ToUpper方法,因为您希望November而不是NOVEMBER.

You need to use dd MMMM yyyy format instead. And don't use ToUpper method since you want November not NOVEMBER.

this.txtInceptiondate.Text = DateTime.Now.ToString("dd MMMM yyyy", CultureInfo.InvariantCulture);

进一步阅读:

这篇关于如何获得具有完整月份名称的完整日期,如2015年11月2日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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