ActiveCampaign Forum

Format of custom date field values on contacts


#1

Hello!

What is the format of custom fields with type=‘date’?

For example, we have two custom fields on Contacts:

{
  "title": "Date Created",
  "descript": null,
  "type": "date",
  "isrequired": "0",
  "perstag": "DATE_CREATED",
  "defval": null,
  "show_in_list": "0",
  "rows": "0",
  "cols": "0",
  "visible": "1",
  "service": "",
  "ordernum": "0",
  "cdate": null,
  "udate": null,
  "options": [],
  "relations": [
    "328"
  ],
  "links": {
    "options": "https:\/\/brandontest.api-us1.com\/api\/3\/fields\/319\/options",
    "relations": "https:\/\/brandontest.api-us1.com\/api\/3\/fields\/319\/relations"
  },
  "id": "319"
}

and

{
  "title": "custom date field",
  "descript": "",
  "type": "date",
  "isrequired": "0",
  "perstag": "CUSTOM_DATE_FIELD",
  "defval": "",
  "show_in_list": "0",
  "rows": "0",
  "cols": "0",
  "visible": "1",
  "service": "",
  "ordernum": "123",
  "cdate": "2019-07-23T19:22:07-05:00",
  "udate": "2019-07-23T19:22:07-05:00",
  "options": [],
  "relations": [
    "329"
  ],
  "links": {
    "options": "https:\/\/brandontest.api-us1.com\/api\/3\/fields\/320\/options",
    "relations": "https:\/\/brandontest.api-us1.com\/api\/3\/fields\/320\/relations"
  },
  "id": "320"
}

both have type=‘date’… but when we load values of these fields for a contact they have different formats:

"fieldValues": [
{
  "contact": "15192",
  "field": "319",
  "value": "9\/22\/13",
  "cdate": "2019-07-23T10:35:39-05:00",
  "udate": "2019-07-23T10:35:39-05:00",
  "links": {
    "owner": "https:\/\/brandontest.api-us1.com\/api\/3\/fieldValues\/44104\/owner",
    "field": "https:\/\/brandontest.api-us1.com\/api\/3\/fieldValues\/44104\/field"
  },
  "id": "44104",
  "owner": "15192"
},
{
  "contact": "15192",
  "field": "320",
  "value": "2019-07-03",
  "cdate": "2019-07-23T19:22:19-05:00",
  "udate": "2019-07-23T19:22:19-05:00",
  "links": {
    "owner": "https:\/\/brandontest.api-us1.com\/api\/3\/fieldValues\/51236\/owner",
    "field": "https:\/\/brandontest.api-us1.com\/api\/3\/fieldValues\/51236\/field"
  },
  "id": "51236",
  "owner": "15192"
}

],

How should we know which format to use to parse actual date from these string representations?