When trying to set a date field's value in an event receiver I get the following error (from the SP log file). How should I be setting the date field's value?
Field in List Definition:
<Field ID="{...}"
Name="DateField"
Type="DateTime"
Format="DateTime"
StorageTZ="UTC"
DisplayName="Date Field"
Description="..."
SourceID="http://schemas.microsoft.com/sharepoint/v3"
Required="FALSE"/>
ItemAdding() snippet:
properties.AfterProperties[fields["Date Field"].InternalName] = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now).ToString();
A trace of what SPUtility returns:
2008-09-30T10:53:28Z
Error in log:
Error loading and running event receiver <...>.<...>ListItemHandler in <...>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=<...>. Additional information is below. : Value does not fall within the expected range.