Time Class

MSBuild

Gets the current date and time.


Namespace: MSBuild.Community.Tasks
Assembly: MSBuild.Community.Tasks (in MSBuild.Community.Tasks.dll)

Syntax

Visual Basic (Declaration)
Public Class Time
    Inherits Task
C#
public class Time : Task
C++
ref class Time : Task
J#
public class Time extends Task
JScript
public class Time extends Task

Example

Using the Time task to get the Month, Day, Year, Hour, Minute, and Second:

 Copy Code
            <Time>
              <Output TaskParameter="Month" PropertyName="Month" />
              <Output TaskParameter="Day" PropertyName="Day" />
              <Output TaskParameter="Year" PropertyName="Year" />
              <Output TaskParameter="Hour" PropertyName="Hour" />
              <Output TaskParameter="Minute" PropertyName="Minute" />
              <Output TaskParameter="Second" PropertyName="Second" />
            </Time>
            <Message Text="Current Date and Time: $(Month)/$(Day)/$(Year) $(Hour):$(Minute):$(Second)" />
Set property "BuildDate" to the current date and time:
 Copy Code
            <Time Format="yyyyMMddHHmmss">
                <Output TaskParameter="FormattedTime" PropertyName="buildDate" />
            </Time>

Remarks

See DateTimeFormatInfo for the syntax of the format string.

Inheritance Hierarchy

System.Object
   Microsoft.Build.Utilities.Task
      MSBuild.Community.Tasks.Time

Thread Safety

Public static (Shared in Visual Basic)staticShared members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

See Also

Syntax based on .NET Framework version 2.0.
Documentation version 1.0.0.0.