Asp.net Get/Set Date and Time as String
In many occasions all we may need is simple date and time.
Now property gives more information which needs to be trimmed down using Format function. Here we have two handy string type properties from Microsoft.
Returns or sets a String value representing the current time of day according to your system.
TimeString always returns the system time as “HH:mm:ss“, which is a 24-hour format. This format is culture-invariant, which means it does not change even if you change the Regional Options in Control Panel.
Dim MyTime As String = TimeString If CInt(TimeString.Substring(0, 2))Â < 12 Then MyGreeting = Reverse("Good Morning") Else MyGreeting = Reverse("Good Afternoon") End If
Timeofday : returns / sets the same but as date datatype.
DateString always returns the system date as “MM-dd-yyyy“, which uses the abbreviated month name.
These formats are culture-invariant, which means they do not change even if you change the Regional Options in Control Panel.
Today : returns / sets the same but as date datatype.