如何转换日期时间"06/01/16"至2016年6月1日"在C#中 [英] How to convert the date time "06/01/16" to 06/01/2016" in C#

查看:204
本文介绍了如何转换日期时间"06/01/16"至2016年6月1日"在C#中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#中将日期时间"06/01/16"转换为06/01/2016"

我尝试过的事情:

无法转换为dd-mm-yyyy

How to convert the date time "06/01/16" to 06/01/2016" in C#

What I have tried:

Not possible to convert to dd-mm-yyyy

推荐答案

尝试此

try this

string date = DateTime.ParseExact("06/01/16", "dd/MM/yy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy"); //"06/01/2016"


DateTime original = Convert.ToDateTime("06/01/16");
DateTime converted = Convert.ToDateTime(original.ToString("dd/MM/yyyy"));


这篇关于如何转换日期时间"06/01/16"至2016年6月1日"在C#中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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