I’m trying to create a new record where one of the fields is a DataTime field.
I always get the “The date-time format for Thu Sep 01 19:25:20 2011 is invalid, or value is outside the supported range.” error.
I’ve tried multiple format options. With Date.parse, Date.parseExact, … Here ‘s my last attempt:
//date input format = 2011-02-15 11:05:22
var year = register_date.substring(0, 4);
var month = register_date.substring(5, 7);
var day = register_date.substring(8, 10);
var hours = register_date.substring(11, 13);
var minutes = register_date.substring(14, 16);
var seconds = register_date.substring(17, 19);
var datetime = Date(Date.UTC(year, month, day, hours, minutes,seconds));
//var datetime = Date.parseExact(register_date, "yyyy-mm-dd HH:mm:ss");
regFields[4] = new CRMField("ave_subscriptiondate", datetime);
Include the code below and you can just do:
This code was found in this useful CRM 2011 JS library
Or if you want them as regular functions instead of extensions on Date such as
dateToCRMFormat(datetime)