Skip to content

Rule.io SDK


Rule.io SDK / client/src / formatDateForRule

Function: formatDateForRule()

formatDateForRule(date): string

Defined in: client/src/utils/date.utils.ts:15

Format a date for the Rule.io API (YYYY-MM-DD). Uses UTC — a local date near midnight may format as the next/previous day.

Use this when setting date-type subscriber custom field values via RuleClient.

Parameters

date

Date

Returns

string

Example

typescript
client.setCustomFieldData(subscriberId, {
  [customFields['Order.Date']]: formatDateForRule(new Date()),
});