I have to convert string in mm/dd/yyyy format to datetime variable but it should remain in mm/dd/yyyy format.
string strDate = DateTime.Now.ToString("MM/dd/yyyy");
Please help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are looking for the
DateTime.Parse()method (MSDN Article)So you can do:
Which will give you a
DateTimetyped object.If you need to specify which date format you want to use, you would use
DateTime.ParseExact(MSDN Article)Which you would use in a situation like this (Where you are using a British style date format):