如何字符串值,07月28日00:00转换成日期时间在c# [英] How to convert string value Jul 28 00:00 to datetime in c#
本文介绍了如何字符串值,07月28日00:00转换成日期时间在c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要转换字符串值 07月28日00:00
,格式datetime值 YYYY-MM-DD AM 00:00
?
Need to convert string value Jul 28 00:00
to datetime value in the format yyyy-MM-dd AM 00:00
?
这是最好的方式这样做呢?
Which is the best way for doing it?
推荐答案
这个怎么样
string[] initDate = textBox1.Text.Split(' ');
string[] time = initDate[2].Split(':');
DateTime dt = new DateTime(DateTime.Now.Year, DateTime.ParseExact(initDate[0], "MMM", CultureInfo.CurrentCulture).Month, int.Parse(initDate[1]), int.Parse(time[0]), int.Parse(time[1]), 0);
string newDate = dt.ToString("yyyy-MM-dd tt HH:mm");
这篇关于如何字符串值,07月28日00:00转换成日期时间在c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文