O'Reilly logo

A Programmer's Guide to .NET by Alexei Fedorov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.4. Formatting date and time values

In Chapter 3, we saw how to use the various formatting specifiers to produce the string representation of values in different formats. Here we will look at how to use the date and time format strings to represent the DateTime data type in various formats. Without providing much reference information about the format specifiers available, let's look at an example that shows how to use each format specifier available – its output shows you exactly what to expect in each case (see also Figure 5.7):

 '---------------------------------------- ' .NET DateTime formatting example '---------------------------------------- Imports System Module Module1 Sub Main() Dim Formats() As String = _ {"Short date : {0:d}", _ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required