Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert date to 'ccyymmddhhmmss' format?

How to convert date to 'ccyymmddhhmmss' format in c#?

like image 337
Narasimha Avatar asked Dec 25 '22 13:12

Narasimha


1 Answers

You might want to try this... I don't know if cc is included, so I solved for the cc.

DateTime time = DateTime.Now;
string format = "yyMMddhhmmss";
Console.WriteLine(((Convert.ToInt32(time.ToString("yyyy")) / 100) + 1).ToString() + time.ToString(format));

For "yyMMddhhmmss".....Try this...And don't forget that capital M is Month and lower case m is minutes.

DateTime dt = Convert.ToDateTime("8 Oct 10 19:00");
Console.WriteLine(dt.ToString("yyMMddhhmmss"));
like image 79
chris_techno25 Avatar answered Jan 06 '23 22:01

chris_techno25