Convert.ToDateTime('Datestring')转换为日期的必需dd-MM-yyyy格式 [英] Convert.ToDateTime('Datestring') to required dd-MM-yyyy format of date
本文介绍了Convert.ToDateTime('Datestring')转换为日期的必需dd-MM-yyyy格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个日期字符串,可以是任何日期格式,但我想将其转换为 dd-MM-yyyy
格式.
我尝试了每个仅转换为系统格式的 Convert.ToDatetime
选项.我希望它转换 dd-MM-yyyy
格式.
I have string of Date which can be in any format of date but I wanted to convert it to dd-MM-yyyy
format.
I have tried every Convert.ToDatetime
option which converts only to the System format. I want it to convert dd-MM-yyyy
format.
请回复.预先感谢.
推荐答案
尝试一下
DateTime dateTime = new DateTime();
dateTime = Convert.ToDateTime(DateTime.ParseExact("YouDateString", "dd-MM-yyyy", CultureInfo.InvariantCulture));
这将返回 DateTime
和您的 Format
这篇关于Convert.ToDateTime('Datestring')转换为日期的必需dd-MM-yyyy格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文