I am facing a small issue which i am not able after trying so many things so here it goes ..... There is a text box in my page in which i am entering date and i want that date in a datetime object.
for ex :
date entd : 6 05 2020(dd/MM/yyyy) should be in same format when i am accessing it in date time object but it is getting changed to (6.05.2020ie: MM/dd/yyyy format).
i hope i am making sense here all i want is some thing like this.....
DateTime dt = convert.ToDateTime(txtDate.Text);
dt should be (11/2/2010 rather then 2/11/2010)
@oded after using the following code
DateTime sDate, eDate = new DateTime();
//To modify dates for our use.
DateTime.TryParseExact(txtFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out sDate);
DateTime.TryParseExact(txtFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out eDate);
What i am getting in edate and sdate is 6 05 2020 12:00:00 AM where it should be 6/05/2020
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…