Time/Date Format Problem

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

    #1

    Time/Date Format Problem

    I am trying to convert a string to datetime format and I get an invalid
    Date/Time format error. The code I am trying to use is:

    msgtime = CDate("Sat, Aug 27 2005 20:00:00 EDT")

    I know I can use this format to generete a valid date but how do I correctly
    covert time zones?

    msgtime = CDate("Sat, Aug 27 2005 20:00:00 GMT")

    Any help would be greatly appercaited.

    Thanks,
    Curtis


  • Cor Ligthert [MVP]

    #2
    Re: Time/Date Format Problem

    Curtis,

    If you use a datestring, than it has to be in the culture of the computer or
    you have to set the culture (something I will not advice you except if you
    directly set it back).

    Therefore every datetime string is in almost every country in the world
    different.

    Is this a valid datetime string in your culture?

    You know that the most nice method to get a date is using the ISO date with
    new date

    dim dtm as datetime = new date(2005,9,1,1 2,18,00)

    I hope this helps,

    Cor


    Comment

    • Curtis

      #3
      Re: Time/Date Format Problem

      Cor,

      Thanks for the reply, so if I understand you correctly their is no way that
      VB will convert times from different time zones ? My application has to
      process time zones that are in the United States so does that mean I have to
      process the time difference manually?

      Thanks,
      Curtis
      "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
      news:usgzQYxrFH A.3080@TK2MSFTN GP15.phx.gbl...[color=blue]
      > Curtis,
      >
      > If you use a datestring, than it has to be in the culture of the computer
      > or you have to set the culture (something I will not advice you except if
      > you directly set it back).
      >
      > Therefore every datetime string is in almost every country in the world
      > different.
      >
      > Is this a valid datetime string in your culture?
      >
      > You know that the most nice method to get a date is using the ISO date
      > with new date
      >
      > dim dtm as datetime = new date(2005,9,1,1 2,18,00)
      >
      > I hope this helps,
      >
      > Cor
      >[/color]


      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Time/Date Format Problem

        Curtis,

        Normally I have readed that the best approaches for this is to use Zulu time
        (z).

        That is another word for UTC which is the same as GMT time.

        There is a lot written about that on internet when you search for those
        three keywords.

        For getting the zulu time is this keyword in the DateTime
        http://msdn.microsoft.com/library/de...tcnowtopic.asp

        The same is in the ToString when you see in this page for the z.

        http://msdn.microsoft.com/library/de...classtopic.asp

        I hope this helps,

        Cor


        Comment

        Working...