AI OnAI Off
Hi Vishal,
If you're looking to set a value to a field on creation of the page you can override the SetDefaultValues method as shown below.
public override void SetDefaultValues(ContentType contentType) { base.SetDefaultValues(contentType); PublicationDate = DateTime.Today.ToString("dd-MM-yyyy"); }
This is then called automatically just the once when the page is created.
Hi Guys,
is there a elegant way of getting the current date in a string property when creating a page with this property.
And no the field cannot be a regular DateTime field, because we are using DXC and all simple dates added here are converted to UTC by default so the day changes, and we want the simple date of publishing all over the world. (lots of threads about this problem) works great in other situations but not when you just want to show the date all over the world.
So what would be a approach to get the date in a string field on creation. ( in a certain format).