using System; using System.Collections.Generic; using System.Text; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using System.Web.UI; using System.Web.UI.WebControls; namespace CustomFieldCurrentDateTime { public class CurrentDateTime : SPFieldDateTime { public CurrentDateTime(SPFieldCollection fields, string fieldName) : base(fields, fieldName) { this.Type = SPFieldType.DateTime; this.DisplayFormat = SPDateTimeFieldFormatType.DateTime; this.DefaultValue = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt"); } public CurrentDateTime(SPFieldCollection fields, string typeName, string displayName) : base(fields, typeName, displayName) { this.Type = SPFieldType.DateTime; this.DisplayFormat = SPDateTimeFieldFormatType.DateTime; this.DefaultValue = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt"); } public override string DefaultValue { get { return DateTime.Now.ToString("dd/MM/yyyy hh:mm tt"); } set { } } public override object DefaultValueTyped { get { return DateTime.Now; } } } }