Public Class Tester Public Shared Sub Main Dim rightNow As Date = Now Dim result As New System.Text.StringBuilder result.AppendLine("""Now""...") ' ----- Use format specifiers to control the date display. result.Append("d: ").AppendLine(rightNow.ToString("d")) result.Append("D: ").AppendLine(rightNow.ToString("D")) result.Append("t: ").AppendLine(rightNow.ToString("t")) result.Append("T: ").AppendLine(rightNow.ToString("T")) result.Append("f: ").AppendLine(rightNow.ToString("f")) result.Append("F: ").AppendLine(rightNow.ToString("F")) result.Append("g: ").AppendLine(rightNow.ToString("g")) result.Append("G: ").AppendLine(rightNow.ToString("G")) result.Append("M: ").AppendLine(rightNow.ToString("M")) result.Append("R: ").AppendLine(rightNow.ToString("R")) result.Append("s: ").AppendLine(rightNow.ToString("s")) result.Append("u: ").AppendLine(rightNow.ToString("u")) result.Append("U: ").AppendLine(rightNow.ToString("U")) result.Append("y: ").AppendLine(rightNow.ToString("y")) Console.WriteLine(result.ToString) End Sub End Class
Now"... d: 11/05/2007 D: May 11, 2007 t: 9:09 PM T: 9:09:27 PM f: May 11, 2007 9:09 PM F: May 11, 2007 9:09:27 PM g: 11/05/2007 9:09 PM G: 11/05/2007 9:09:27 PM M: May 11 R: Fri, 11 May 2007 21:09:27 GMT s: 2007-05-11T21:09:27 u: 2007-05-11 21:09:27Z U: May 12, 2007 4:09:27 AM y: May, 2007