Converting user input date into required format

Description



The following snippet is used to convert the given date format into required date format.

DateTime d1= DateTime.ParseExact("181209", new string[]{"dMy","d/M/y"},null ,System .Globalization . DateTimeStyles.None);

Response.Write(d1.ToShortDateString ());




Explanation:
The DateTime.ParseExact method takes 4 arguments
First argument is input date
Second argument is required format to be changes to
Third argument is null
Fourth argument is defining datetimestyle.


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: