Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| ' Visual Basic .NET Document | |
| Option Strict On | |
| ' <Snippet22> | |
| Imports System.Globalization | |
| Module Example | |
| Public Sub Main() | |
| Dim fmt As String = "dd MMM yyyy hh:mm tt ""pst""" | |
| Dim dat As New Date(2016, 8, 18, 16, 50, 0) | |
| ' Display the result string. | |
| Console.WriteLine(dat.ToString(fmt)) | |
| ' Parse a string. | |
| Dim value As String = "25 Dec 2016 12:00 pm pst" | |
| Dim newDate As Date | |
| If Date.TryParseExact(value, fmt, Nothing, | |
| DateTimeStyles.None, newDate) Then | |
| Console.WriteLine(newDate) | |
| Else | |
| Console.WriteLine("Unable to parse '{0}'", value) | |
| End If | |
| End Sub | |
| End Module | |
| ' The example displays the following output: | |
| ' 18 Aug 2016 04:50 PM pst | |
| ' 12/25/2016 12:00:00 PM | |
| ' </Snippet22> |