Changing a DateTime format --- please help!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • almurph@altavista.com

    Changing a DateTime format --- please help!

    Hi,

    Hope that you can help me with this. I'm calling DateTime.Now and
    storing in a DateTime container. I see that the pattern format is: m/
    dd/yyyy

    I need it to be in the format: yyyy-MM-dd HH:MM:SS as type DateTime
    but I don't know how to do this! Can anyone help me please? Any
    comments/advice/suggestions/code-sampels much appreciate.

    Cheers,
    Al.
  • BlackWasp

    #2
    Re: Changing a DateTime format --- please help!

    As others have said, if you are converting to a string representation of the
    date, use ToString(). There is a whole heap to think about here though
    including globalisation (if the application is not for a particular
    local-region-only solution).

    I have put together an article on DateTime manipulation that includes
    information on standard formats and "Picture" formatting at
    http://www.blackwasp.co.uk/CSharpDateManipulation.aspx.

    --

    BlackWasp



    <almurph@altavi sta.comwrote in message
    news:1ecd7275-44bc-4185-bc74-50abcb624c79@u7 2g2000hsf.googl egroups.com...
    Hi,
    >
    Hope that you can help me with this. I'm calling DateTime.Now and
    storing in a DateTime container. I see that the pattern format is: m/
    dd/yyyy
    >
    I need it to be in the format: yyyy-MM-dd HH:MM:SS as type DateTime
    but I don't know how to do this! Can anyone help me please? Any
    comments/advice/suggestions/code-sampels much appreciate.
    >
    Cheers,
    Al.

    Comment

    • Rad [Visual C# MVP]

      #3
      Re: Changing a DateTime format --- please help!

      On Wed, 27 Feb 2008 09:42:42 -0800 (PST), almurph@altavis ta.com wrote:
      Hi,
      >
      Hope that you can help me with this. I'm calling DateTime.Now and
      storing in a DateTime container. I see that the pattern format is: m/
      dd/yyyy
      >
      I need it to be in the format: yyyy-MM-dd HH:MM:SS as type DateTime
      but I don't know how to do this! Can anyone help me please? Any
      comments/advice/suggestions/code-sampels much appreciate.
      >
      Cheers,
      Al.
      As has been suggested, one way is to use ToString() with the appropriate
      format specifiers.

      --

      Comment

      Working...