Arrow
Arrow

Reputation: 321

how to get current date and time in visual studio 2008?

I am trieng to get the current date and time in my website. I am using the following function to get date and time.

Response.Write( DateTime.Now.Date );

I am getting the date properly but for the time I am getting as 12:00 AM . Please someone tell me how to get the current time along with the date.

Upvotes: 1

Views: 5351

Answers (1)

adrianbanks
adrianbanks

Reputation: 83004

You can just use DateTime.Now and it will give both the current date and time.

By calling the additional .Date property, you are getting a date and time with the time portion set to midnight (as documented).

Upvotes: 3

Related Questions