convert between timzones?-VBForums
Results 1 to 3 of 3

Thread: convert between timzones?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    6

    convert between timzones?

    Hi
    I need to parse a string with time info from one timezone
    and output as another string with the time info for another
    timezone.

    ex. "19880311 23:44:35 Moscow" > "yyyyMMdd HH:mm:ss NewYork"

    it must observe DST, parse the input with format string and
    allow output to be formatted with a formatting string
    the city names are not important and can be replaced
    with f.ex. timezone codes

    thank you
    and best regards

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    96,549

    Re: convert between timzones?

    You should look at the TimeZoneInfo class. It can help you convert date and time from one time zone to another. You can use DateTime.TryParseExact to convert the String to a DateTime first.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    6

    Re: convert between timzones?

    thanks jm, I know about the ParseExact, I have tried this:
    Debug.WriteLine(TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt, TimeZoneInfo.Local.Id, "Pacific Standard Time"))
    It works. but
    Debug.WriteLine(TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt, "India Standard Time", "Pacific Standard Time"))
    is not working..It seems like I can only convert from local time

    br

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.