Search code examples
visual-studio-2010visual-studiovisual-c++textboxhour

How to insert the date and hour time in Visual Studio?


I use Visual Studio 2010. I want to put the current date and hour in my TextBox.

I used this code in expression text : =Today()

I put this code here, in the Value box:

Placeholder properties dialog

I have this output:

14/07/2015 00:00:00

I would like to also have the hour. (For example, 10:43:10.)

How can I do this?


Solution

  • What you are looking for is Now() property.

    From MSDN:

    Now(): Returns a Date value containing the current date and time according to your system.

    Today(): The Date data type includes time components. When returning the system date, Today sets all of these to 0, so the returned value represents midnight (00:00:00). When setting the system date, Today ignores the time components.

    TimeOfDay(): The Date data type includes date components. When returning the system time, TimeOfDay sets these all to 1, so that the returned value represents the first day of the year 1. When setting the system time, TimeOfDay ignores the date components.