-1

I have a lot of data with timestamps in the following format: 20150603005845. I need to parse this and turn it into 2015/06/03 00:58:45 AM. I know I can convert it into a string and break it up and parse it the hard way but I was wondering if there are any inbuilt classes that can help me achieve this. I'm new to C# and don't know if there are any methods that can help me do this. Any help will be appreciated!

sparta93
  • 3,684
  • 5
  • 32
  • 63
  • Maybe this might help? Just a quick search so I'm not sure how relevant it would be... http://stackoverflow.com/questions/249760/how-to-convert-unix-timestamp-to-datetime-and-vice-versa – Broots Waymb Jun 29 '15 at 20:17

1 Answers1

2

Parse date:

var date = DateTime.ParseExact("20150603005845", "yyyyMMddHHmmss", CultureInfo.InvariantCulture);

Format date:

string formattedDate = date.ToString("yyyy/MM/dd HH:mm:ss tt");
Andriy Horen
  • 2,861
  • 4
  • 18
  • 38