Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTime format string

Tags:

c#

.net

DateTime date = DateTime.Parse("2011-05-04 14:33:41"); //4 may 2011

How do I convert this date to "20110504 14:33:41"?

like image 383
Alexandre Avatar asked May 13 '11 07:05

Alexandre


1 Answers

Format it like this

string formattedDate = date.ToString("yyyyMMdd HH:mm:ss");
like image 117
Øyvind Bråthen Avatar answered Oct 01 '22 18:10

Øyvind Bråthen