Question

I have a easy question but hard to do for me. I have a date time value.

DateTime? Date;

Date has value like 4/2/2014. How can i change this value to 04/02/2014?

Was it helpful?

Solution

A DateTime doesn't have a format - it only gets a format when it's displayed. If you don't specify a format (like when viewing in the debugger), a default one will be chosen depending on the control type and current culture.

So the right answer depends on how you're displaying the date. If you're using ToString:

Date.Value.ToString("MM/dd/yyyy")

If you're using some sort of control read the docs on how to specify value formats.

OTHER TIPS

here :)

dateTime thisDate = date.today.ToString("MMMM dd, yyyy") + ".");

you can also parse your string date like this

DateTime MyDate = Convert.ToDateTime("4/2/2014")
string te = t.ToString("DD, MM, YYYY");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top