Assume a date and time string formatted for the fr-FR culture is the local time and convert it to UTC
Imports System.Globalization
Module ParseDateExample
Public Sub Main()
Dim dateString As String
Dim culture As CultureInfo
Dim styles As DateTimeStyles
Dim result As DateTime
dateString = "2010-03-01 10:00"
culture = CultureInfo.CreateSpecificCulture("fr-FR")
styles = DateTimeStyles.AdjustToUniversal Or DateTimeStyles.AssumeLocal
Try
result = DateTime.Parse(dateString, culture, styles)
Console.WriteLine("{0} converted to {1} {2}.", _
dateString, result, result.Kind.ToString())
Catch e As FormatException
Console.WriteLine("Unable to convert {0} to a date and time.", dateString)
End Try
End Sub
End Module
Related examples in the same category