如何在c#.net中更改日历的格式

时间:2014-10-27 18:41:50

标签: c# .net winforms

 protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = "Select Date:-";
        Calendar1.SelectedDate = DateTime.Now;
    }

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {

        Label1.Text = Label1.Text + Calendar1.SelectedDate.ToShortDateString();

    }

在标签中,它以mm-dd-yyyy格式显示 但我希望格式为dd-mm-yyyy。

1 个答案:

答案 0 :(得分:1)

试试这个:

Label1.Text = Label1.Text + Calendar1.SelectedDate.ToString("dd-MM-yyyy");