Question:

What is the best way for me to format date using C#?

by  |  earlier

0 LIKES UnLike

"15-Nov-07" I need to turn into "11/15/2007" using C#.

How do I do that?

 Tags:

   Report

3 ANSWERS


  1. Try using the Parse() method of the DateTime value type.

    string MyDateString = "15-Nov-07";

    DateTime MyDateTime = DateTime.Parse(MyDateString);

    MessageBox.Show( MyDateTime.ToShortDateString() );


  2. on your form

    add a button and a label called label1

    add this to button1's event handler

    label1.Text = DateTime.Now.ToString();

    and run your code and click on button1

    hope this helps

  3. hay dude v have a control DateTimePicker and next there is property dateformat in property box  change the format to required one .Take care

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.