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?

有帮助吗?

解决方案

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.

其他提示

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");
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top