문제

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