How can I convert a datetime string like December 13, 2015 09:55 PM
to a DateTime
?
Asked
Active
Viewed 115 times
-3

YWah
- 571
- 13
- 38
-
please add appropriate tags. – Nuetrino Dec 13 '15 at 14:02
-
Have you tried `DateTime.Parse(string)`? – Camilo Terevinto Dec 13 '15 at 14:02
-
Or `DateTime.ParseExact` with an appropriate format? There are *lots* of date/time conversion questions on Stack Overflow - please research them to give you a starting point, and if you can't make progress, show what you've tried. – Jon Skeet Dec 13 '15 at 14:03
2 Answers
1
Try this
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);
}
}
}

jdweng
- 33,250
- 2
- 15
- 20