将字符串(12小时格式的长日期和时间)转换为DateTime

时间:2015-12-13 14:00:20

标签: c# string datetime

如何将日期时间字符串December 13, 2015 09:55 PM转换为DateTime

2 个答案:

答案 0 :(得分:1)

试试这个

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string strDate = "December 13, 2015 09:55 PM";
            DateTime date = DateTime.ParseExact(strDate, "MMMM dd, yyyy hh:mm tt", CultureInfo.InvariantCulture);

        }
    }
}
​

答案 1 :(得分:0)

DateTime.Parse("December 13, 2015 09:55 PM")