On This Page

Next

SDK Examples

Previous

Build and Deploy

Date Examples


Current Date

The first example will simply return the current date in short date format:


	public class CurrentDate : IPropertyFunction
	{
		public string Execute(TemplateContext context, IServiceLocator services)
		{
			return DateTime.Now.ToShortDateString();
		}
	}

The code for this example is located in src/Dovetail.PropertyExtensionExamples/Functions/CurrentDate.cs.

Current Date & Time

The second example will simply return the current date and time:


	public class CurrentDateTime : IPropertyFunction
	{
		public string Execute(TemplateContext context, IServiceLocator services)
		{
			return DateTime.Now.ToString("g");
		}
	}

The code for this example is located in src/Dovetail.PropertyExtensionExamples/Functions/CurrentDateTime.cs.