Click to See Complete Forum and Search --> : Change DateTime.Now format to ISO 8601


raulbolanos
June 12th, 2009, 04:49 AM
Hello guys,

I get this time from DateTime.Now "6/12/2009 11:45:28 AM" and I need to convert it ISO 8601 which is the one that SQL accepts "2009-12-06 11:45:28".

What can I do?

raulbolanos
June 12th, 2009, 05:11 AM
I found a way to do this


DateTime lastTime = DateTime.Now;
string x = lastTime.ToString("u").Replace("Z", "");


but I need to do this in 1 step because I send this time by parameters, i,e:


Insert(DateTime.Now);


And I would like to send the time through it

raulbolanos
June 12th, 2009, 07:07 AM
solved

eclipsed4utoo
June 12th, 2009, 10:56 AM
Insert(DateTime.Now.ToString("u").Replace("Z", ""));