Convert MMDDYYYY to 01-JAN-YY

I have a string in the format in = "01012012". I want him to convert to: 01-JAN-12. How to achieve this in C #?

+4
source share
2 answers
DateTime dateTime = DateTime.ParseExact("01012012", "MMddyyyy", CultureInfo.InvariantCulture); string newDateString = dateTime.ToString("dd-MMM-yy"); 

EDIT: Changed output to 2-digit date (instead of 4)

+14
source

Got my answer:

  CultureInfo provider = CultureInfo.InvariantCulture; DateTime date = DateTime.ParseExact("08312012", "MMddyyyy", provider); string getDate = date.ToString("dd-MMM-yy"); 

Thanks guys!!!

0
source

Source: https://habr.com/ru/post/1437092/


All Articles