将日期转换为特定格式 [英] Conversion of Date to specific format

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

问题描述

我得到了这样的日期12/27/2013 12:00:00 AM



如何在C#中将其转换为'2013/12/27'? ??



我尝试使用这个DateTime.ParseExact(txtBxFromDate.Text,yyyy / M / d,null);

I got date like this 12/27/2013 12:00:00 AM

how to convert this to '2013/12/27' in C#???

I tried using this DateTime.ParseExact(txtBxFromDate.Text, "yyyy/M/d", null);

推荐答案

试试这个。

Try this.
DateTime.ParseExact(txtBxFromDate.Text, "yyyy/MM/dd", null);





参考:日期格式 [ ^ ]


DateTime currentDate = DateTime.Now();
string date = currentDate.toString("yyyy/MM/dd"); // [2014/01/09]


尝试这样: -

try like this:-
DateTime.ParseExact(txtDt.Text, "yyyy/MM/dd", null).ToString()





根据需要指定格式而不是yyyy / MM / dd。



specify format instead of "yyyy/MM/dd" as you required.


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

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