Converting date formats

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam

    #1

    Converting date formats

    Hi,

    What is the easiest way to create a DateTime object from
    a string of the format:
    1998-06-22T13:00

    (i.e. 22nd June 1998, 1pm)

    I've tried splitting the string up, but this seems rather
    complicated. Is there a simpler way to do this?

    Regards,

    Adam.
  • Noah Coad [MVP .NET/C#]

    #2
    Re: Converting date formats

    Just use the DateTime.ParseE xact method to create a DateTime object with
    your particular format.

    DateTime dt = DateTime.ParseE xact("1998-06-22T13:00", @"yyyy-MM-dd\THH:mm",
    System.Globaliz ation.DateTimeF ormatInfo.Invar iantInfo);
    -Noah Coad
    Microsoft MVP & MCP [.NET/C#]

    "Adam" <adam@twv.org > wrote in message
    news:1b9501c352 c1$3f600910$a00 1280a@phx.gbl.. .[color=blue]
    > Hi,
    >
    > What is the easiest way to create a DateTime object from
    > a string of the format:
    > 1998-06-22T13:00
    >
    > (i.e. 22nd June 1998, 1pm)
    >
    > I've tried splitting the string up, but this seems rather
    > complicated. Is there a simpler way to do this?
    >
    > Regards,
    >
    > Adam.[/color]


    Comment

    Working...