Asp.net Get/Set Date and Time as String(gchandra.wordpress.com)

submitted by gchandragchandra(330) 4 years, 8 months ago

In many occasions all we may need is simple date and time. "Now" gives more information which needs to be trimmed down using Format function. Here we have two handy string type properties from Microsoft.

1 comment |category: |Views: 3

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by jamesewelchjamesewelch(2275) 4 years, 8 months ago 0

Why not use DateTime.Now.Hour instead of converting DateTime.Now to a string via string.format, then parsing it via substring, and then converting it to an int to do a comparison?

http://msdn2.microsoft.com/en-us/library/system.datetime_members.aspx

Could just be rewritten to say
MyGreeting = iif ( DateTime.Now.Hour < 12 , "Good Morning" , "Good Afternoon")

(having done vb in a while, unsure of exact iif statement)

Reply

information Login or create an account to comment on this story