在日期转换中将字符串转换为system.iformatprovider [英] convert string to system.iformatprovider in date conversion
本文介绍了在日期转换中将字符串转换为system.iformatprovider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有问题将日期转换为格式(dd-MM-yyyy)和(yyyyMMdd)
我使用了txtsodate.text.ToString(yyyyMMdd)但失败了。
如何在上面设置日期格式格式。请给我建议
Maideen
Hi
I have an issue to convert the date into the format(dd-MM-yyyy) and (yyyyMMdd)
I have used the txtsodate.text.ToString("yyyyMMdd") but failed.
How can set the date format in the above format. Pls advice me
Maideen
推荐答案
如果你有一个日期字符串,你可以先转换它到日期时间 [ ^ ]输入然后再返回再次使用您喜欢的格式的字符串。
例如:
If you have a string with the date you can first convert it to the DateTime[^] type and then back to a string again in the format you prefer.
For example:
string inputData = "12/23/2014"; // American style
DateTime tmpDate = DateTime.ParseExact(inputData, "MM/dd/yyyy", null);
string output1 = tmpDate.ToString("dd-MM-yyyy");
string output2 = tmpDate.ToString("yyyyMMdd");
这是一个不同日期格式的好页面自定义日期和时间格式字符串 [ ^ ]
这篇关于在日期转换中将字符串转换为system.iformatprovider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文