String to DateTime conversion in .NET compact Framework

269 Views Asked by At

I am using .NET compact Framework, more precisely using Windows mobile 6.0 and was trying to convert a string to datetime but seems it is not supported. Any help would be appreciated.

Dim provider AS CultureInfo = New CultureInfo("en-US")
Dim dt AS DateTime = Convert.ToDatetime("5/2/2013 5:15:03 PM") 

Getting a formatexception issue.

1

There are 1 best solutions below

0
devlin carnate On

Please see the following .NET Fiddle here.

Imports System
Imports System.Globalization

Public Module Module1
    Public Sub Main()
        Dim provider AS CultureInfo = New CultureInfo("en-US")
        Dim dt AS DateTime = Convert.ToDatetime("5/2/2013 5:15:03 PM") 
        Console.WriteLine(dt)
        Console.WriteLine(dt.ToString("d",provider))
    End Sub
End Module

Output:

output