I have some code to do with dates that I have been using for while with my page set to "Culture=en-GB". I now need an alternative version of this page with dates in American format MM/DD/YYYY rather than British format DD/MM/YYYY.
I have changed the Culture on the page to en-US, and I am building my date like this :
DateFrom = Convert.ToDateTime(MonthFrom.SelectedItem.Value + "/" + DayFrom.SelectedItem.Value + "/" + YearFrom.SelectedItem.Value);
I then convert the date to my required format (e.g. 15th January 2003 = 1/15/2003) :
DateFrom = Convert.ToDateTime(DateFrom.ToString("d");
This line worked when the page culture was set to en-GB, but it doesn't work with the page culture set to en-US. Instead of 1/15/2003, I get 1/15/2003 12:00:00 AM.
Is there a different way to format dates in en-US? That would be the only explanation for why this doesn't work.
Any help would be really appreciated.
Thanks,
Mike
I have changed the Culture on the page to en-US, and I am building my date like this :
DateFrom = Convert.ToDateTime(MonthFrom.SelectedItem.Value + "/" + DayFrom.SelectedItem.Value + "/" + YearFrom.SelectedItem.Value);
I then convert the date to my required format (e.g. 15th January 2003 = 1/15/2003) :
DateFrom = Convert.ToDateTime(DateFrom.ToString("d");
This line worked when the page culture was set to en-GB, but it doesn't work with the page culture set to en-US. Instead of 1/15/2003, I get 1/15/2003 12:00:00 AM.
Is there a different way to format dates in en-US? That would be the only explanation for why this doesn't work.
Any help would be really appreciated.
Thanks,
Mike