将日期yyyyMMdd转换为system.datetime格式 [英] Convert date yyyyMMdd to system.datetime format

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

问题描述


可能重复:

如何将日期从yyyyMMdd格式转换为mm-dd-yyyy fomrat

我有一个字符串,其中包含yyyyMMdd格式的日期。我想使用 ConvertTo.DateTime()方法或其他任何简单方法将该日期转换为系统日期格式。

I have a string which contains date in yyyyMMdd format. I want to convert that date into system date format using ConvertTo.DateTime() method or any other simple method.

string value = "19851231";  //yyyyMMdd

DateTime dateTime = 1985/12/31;


推荐答案

string time = "19851231";
DateTime theTime= DateTime.ParseExact(time,
                                        "yyyyMMdd",
                                        CultureInfo.InvariantCulture,
                                        DateTimeStyles.None);

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

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