2012-11-02 212 views

回答

4
Console.WriteLine(DateTime.Now.ToString("ddMMyyyy")); 

产生02112012

如果您需要进一步的客户的日期格式,这link应该是有帮助=)

+0

thnks ...会尝试,让你知道 如果日期存储在本地变量Bdate然后? – user1791077

+0

是的,如果你已经有一个'DateTime'对象,只需使用'myObject.ToString(“ddMMyyyy”);'' –

1

像这样:

// parse the original string value into DateTime. 
DateTime dt = DateTime.ParseExact("2012-11-02", "yyyy-MM-dd", 
    CultureInfo.CurrentCulture); 

// emit to your desired format. 
string bookingIdFormattedDate = dt.ToString("ddMMyyyy"); 

// bookingIdFormattedDate should be "02112012" 

干杯。

0
string dateString = "2012-10-01"; 
DateTime date = DateTime.ParseExact(dateString, "yyyy-MM-dd", new DateTimeFormatInfo()); 
string result=date.ToString("ddmmyyyy"); 
相关问题