CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Location
    Stuttgart, Germany
    Posts
    56

    Smile Change DateTime.Now format to ISO 8601

    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?

  2. #2
    Join Date
    Mar 2009
    Location
    Stuttgart, Germany
    Posts
    56

    Re: Change DateTime.Now format to ISO 8601

    I found a way to do this

    Code:
    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:

    Code:
    Insert(DateTime.Now);
    And I would like to send the time through it

  3. #3
    Join Date
    Mar 2009
    Location
    Stuttgart, Germany
    Posts
    56

    Re: Change DateTime.Now format to ISO 8601

    solved

  4. #4
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    Re: Change DateTime.Now format to ISO 8601

    Code:
    Insert(DateTime.Now.ToString("u").Replace("Z", ""));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured