Reformat timestamp attributes

In Customer.io Journeys, you need to format timestamps as Unix epochs to full take advantage of them. If you’ve already uploaded data with timestamps in a different format, you can use the Create or Update Person action to reformat your timestamps.

1. Create a segment with the attribute you want to reformat

When you create your segment, you can use the is not a timestamp condition. This makes sure that you only update attributes that aren’t formatted correctly.

Screen Shot 2020-07-29 at 2.28.08 PM
Screen Shot 2020-07-29 at 2.28.08 PM

2. Create a campaign using your new segment

When you create your campaign make the campaign re-enterable, so you can reformat the timestamp whenever it appears. This campaign won’t send any messages, so you’ll want it to “send” to unsubscribed people as well.

3. Use the Create or Update Person action to fix the typo

The only action in your workflow should be a Create or Update Person block. You’ll replace the current attribute value with a properly formatted timestamp using Liquid filters or JavaScript.

In this example, we’re assuming that our initial value is an ISO date or date-time. If you use Liquid, your code changes depending on whether your initial value is a complete ISO-8601 timestamp or a date-only value in YYYY-MM-DD format. For more about converting dates using Liquid, see our Liquid documentation.

return new Date(customer.date_of_birth).getTime() / 1000;
fix date-time values with JavaScript
fix date-time values with JavaScript
// if date_of_birth has a value like: "1983-03-15T12:00:00Z"
{{customer.date_of_birth | date: "%s"}}
fix date-time values with liquid
fix date-time values with liquid
// if date_of_birth has a value like: "1983-03-15"
{{customer.date_of_birth | append: " 12:00:00" | date: "%Y-%m-%d %H:%M:%S" | date: "%s"}}
fix date-time values with liquid
fix date-time values with liquid

4. Start your campaign

On the review page, select Current people and future additions, so that you correct the timestamp on all current and future people.

set your campaign to capture future people
set your campaign to capture future people
Copied to clipboard!
  Contents
Is this page helpful?