Mega Code Archive

 
Categories / VB.Net Tutorial / Date Time
 

Format the current date in various ways

Imports System Imports Microsoft.VisualBasic Class Sample    Public Shared Sub Main()       Dim thisDate As DateTime = DateTime.Now       Console.WriteLine("Standard DateTime Format Specifiers")       Console.WriteLine("(d) Short date: . . . . . . . {0:d}" & vbCrLf & _                         "(D) Long date:. . . . . . . . {0:D}" & vbCrLf & _                         "(t) Short time: . . . . . . . {0:t}" & vbCrLf & _                         "(T) Long time:. . . . . . . . {0:T}" & vbCrLf & _                         "(f) Full date/short time: . . {0:f}" & vbCrLf & _                         "(F) Full date/long time:. . . {0:F}" & vbCrLf & _                         "(g) General date/short time:. {0:g}" & vbCrLf & _                         "(G) General date/long time: . {0:G}" & vbCrLf & _                         "    (default):. . . . . . . . {0} (default = 'G')" & vbCrLf & _                         "(M) Month:. . . . . . . . . . {0:M}" & vbCrLf & _                         "(R) RFC1123:. . . . . . . . . {0:R}" & vbCrLf & _                         "(s) Sortable: . . . . . . . . {0:s}" & vbCrLf & _                         "(u) Universal sortable: . . . {0:u} (invariant)" & vbCrLf & _                         "(U) Universal full date/time: {0:U}" & vbCrLf & _                         "(Y) Year: . . . . . . . . . . {0:Y}" & vbCrLf, _                         thisDate)    End Sub End Class