以特定格式显示日期 [英] Display date in specific format

查看:103
本文介绍了以特定格式显示日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,如何以2014-12-31的格式显示日期?

我在下面试过但它给了我错误的红线以下我的代码。



Hi, I have the following codes, how can I display the date in a format of "2014-12-31"?
I have tried below but it gives me error red line below of my codes.

dto = new LabelPrintDataDto();
dto.Key = "$DateTime$";
dto.Value = unitdto.ManufactureDate.ToString("yyyy MM dd");
labelPrintDataListDto.DtoList.Add(dto);

推荐答案

DateTime


;
dto.Value = unitdto.ManufactureDate.ToString( yyyy MM dd);
labelPrintDataListDto.DtoList.Add(dto);
"; dto.Value = unitdto.ManufactureDate.ToString("yyyy MM dd"); labelPrintDataListDto.DtoList.Add(dto);


你必须在我的代码下面使用yyyy-MM-dd正常工作:

You must use "yyyy-MM-dd" for me below code is working fine as you expected:
DateTime dt = DateTime.Now;
string formatedDate = dt.ToString("yyyy-MM-dd");



有关更多信息,请查看以下链接,其中包含许多示例代码段:

http://msdn.microsoft.com/en-us/library/8kb3ddd4(v = vs.110).aspx [ ^ ]



谢谢。


And for more have a look on below link with many sample code snippets:
http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx[^]

Thanks.


这篇关于以特定格式显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆