0

Once I select the date, I get it into a textbox in MM/dd/yyyy format.

private void mCalToDate_DateSelected(object sender, DateRangeEventArgs e)
        {
            DateTime dd = new DateTime();
            string temp = e.Start.ToShortDateString();
            if (temp != null && temp != "")
                dd = DateTime.ParseExact(temp.ToString(), "MM/dd/yyyy", CultureInfo.InvariantCulture);
            if (temp != null && temp != "")
                txtTodate.Text = dd.ToString("MM/dd/yyyy");
            mCalToDate.Visible = false;

It works properly in my computer, but in another computer it display in yyyy/MM/dd format. How to rectify this?

  • `/` has a special meaning of "replace me current culture or supplied culture date separator" on custom date time parsing methods. So, it would be better to use a _specific_ culture when you display them. – Soner Gönül Oct 30 '17 at 18:04
  • The result of `.ToShortDateString()` can be different on different cultures. – oerkelens Oct 30 '17 at 18:06

0 Answers0