Script(s)

what I learn is what u c

Asp.net Get/Set Date and Time as String

with one comment

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.

kick it on DotNetKicks.com

About these ads

Written by gchandra

September 4, 2007 at 10:26 am

Posted in Asp.Net

One Response

Subscribe to comments with RSS.

  1. 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


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: