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.
TimeString Property
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.
ex :
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.
ooOoo
DateString Property
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.
Great website. Sometimes I just have to go with my people celebration Nice joke! What do you call a boomerang that doesn’t work? A stick.
obellaweX
October 28, 2008 at 11:06 am