Skip to main content

Manage the date and time in your feeds

Use rule boxes in Dataflow or Data View to manage the date and time in your feed in Productsup.

Introduction

If your product data contains date and time values, you may need to use rule boxes in Dataflow or Data View to manipulate this data.

Productsup offers rule boxes that can perform the following tasks with your date and time values:

  • Add the current date and time to an attribute

  • Convert a date to a timestamp

  • Change the date format

  • Assign, append, or prepend a value based on a date

  • Add a temporary text or discount based on a date

Another option to work with time-bound values is to schedule rule boxes. See Advanced rule box options

Note

You can add a rule box in both Dataflow and Data View. This document describes how to add and set up each rule box in Dataflow.

Add the current date and time to an attribute

You can use the Set Timestamp rule box to overwrite the values in an attribute with the current date and time in a desired timezone and format.

  1. Go to Dataflow and choose the needed export in the drop-down menu on the left.

  2. Select the needed attribute:

    1. To add a rule box between the import and intermediate stages, select an attribute in the intermediate stage.

    2. To add a rule box between the intermediate and export stages, select an attribute in the export stage.

  3. Search for Set Timestamp in the drop-down menu Select an Option and add the rule box.

    set_timestamp_rule_box.png
  4. In Format, enter the date format that the rule box should use to add the current date and time to your attribute. See PHP: date - Manual for the supported formats.

    Tip

    To add a Unix timestamp instead of standard date formats, enter U.

  5. In Timezone, select the needed timezone.

  6. Select Save.

Convert a date to a timestamp

You can use the Convert to Timestamp rule box to convert a date or a date-related text into a Unix timestamp. For example, you can convert the following strings into timestamps:

  • now

  • 2 June 2023

  • +1 week 2 days 4 hours 2 seconds

  • next Thursday

Note

If your values contain only a date without the exact time, for example, 01.02.2023 instead of 01.02.2023 10:48:01, the rule box Convert to Timestamp works as follows:

  • Assumes the time is 00:00 in your current timezone.

  • Converts this time into the GMT timezone.

  • Converts your date into a timestamp using the assumed time in the GMT timezone.

For example, the full date and time 01.02.2023 10:48:01 in the GMT+1 timezone convert to the timestamp 1643708881, but the date without the time converts to 1643670000.

See PHP: strtotime - Manual for the supported string formats you can convert into a timestamp.

To add the rule box, do the following:

  1. Go to Dataflow and choose the needed export in the drop-down menu on the left.

  2. Select the needed attribute:

    1. To add a rule box between the import and intermediate stages, select an attribute in the intermediate stage.

    2. To add a rule box between the intermediate and export stages, select an attribute in the export stage.

  3. Search for Convert to Timestamp in the drop-down menu Select an Option and add the rule box.

    convert_to_timestamp.png
  4. Select Save.

Change the date format

You can use the Convert Datetime Format rule box to change the format of your date and time values.

  1. Go to Dataflow and choose the needed export in the drop-down menu on the left.

  2. Select the needed attribute:

    1. To add a rule box between the import and intermediate stages, select an attribute in the intermediate stage.

    2. To add a rule box between the intermediate and export stages, select an attribute in the export stage.

  3. Search for Convert Datetime Format in the drop-down menu Select an Option and add the rule box.

    convert_format.png
  4. In Source Format, enter your current date format. See PHP: date - Manual for the supported formats.

    Tip

    If you want to convert your date format into a Unix timestamp, the attribute where you apply the rule box needs to contain the full date and time, including hours, minutes, and seconds. If it doesn't, the platform uses the provided date elements and adds the hours, minutes, and seconds of the moment when the rule box last ran. This means the moment when you edited and saved the rule box or the moment of your last site run.

    To assume the missing time elements, the rule box uses the GMT timezone and the H:i:s time format.

  5. In Target Format, enter the desired date and time format. For example, enter U to convert your regular date format into a Unix timestamp. See PHP: date - Manual for other supported formats.

  6. Select Save.

Here is an example of applying the rule box Convert Datetime Format to convert a date into the d-m-Y format:

Current value

Source Format input

Target Format input

Result value

20230525 18:05:45

Ymd H:i:s

d-m-Y

25-05-2023

Here are two (2) more examples of applying the rule box Convert Datetime Format to convert a date into a timestamp. The first one features a current value that contains the full date and time, and the second one shows how the rule box works if your current value doesn't include hours, minutes, and seconds:

Current value

Source Format input

Target Format input

Result value

20230525 18:05:45

Ymd H:i:s

U

1685030745

20230525

Ymd

U

1685008255

Note

The moment when you saved the rule box was at 09:50:55 GMT+0000.

Assign, append, or prepend a value based on a date

You can use the Set Column by Time rule box in a desired attribute to assign, append, or prepend a value from another attribute based on a date-and-time condition. A date-and-time condition works as follows:

  1. In the rule box setup, you choose a date attribute and select whether the date in that attribute should be in the past, future, or now to meet the desired date-and-time condition.

  2. If the date meets the desired date-and-time condition, the platform assigns, appends, or prepends a value from another selected attribute to the attribute where you apply the rule box.

The Set Column by Time rule box may be useful when launching a sale. For example, you are selling a popular sneakers model, but a newer sneakers model is going to drop soon, and you have that release date in your feed. You also have a short sale promo text in another attribute and want to append that short sale promo text to the title of the older sneakers to attract more attention and announce a sale as soon as the newer sneakers model gets released. You can use the Set Column by Time rule box to modify the older sneakers' title:

Current product title

New sneaker release date

Desired date condition

Sale promo text to append

Changed product title

Old sneakers

5 June 2023

in the past

25% OFF

Old sneakers 25% OFF

In this example, the platform checks whether the new sneaker release date is in the past or not. And as soon as that date is in the past, the platform appends the sale promo text to the title of your product.

To add and set up the rule box, do the following:

  1. Go to Dataflow and choose the needed export in the drop-down menu on the left.

  2. Select the needed attribute:

    1. To add a rule box between the import and intermediate stages, select an attribute in the intermediate stage.

    2. To add a rule box between the intermediate and export stages, select an attribute in the export stage.

  3. Search for Set Column by Time in the drop-down menu Select an Option and add the rule box.

    set_column_by_time.png
  4. In Source Column, choose your date attribute.

  5. In Time Format, enter the format used in your date attribute. See PHP: date - Manual for the supported formats.

  6. In the drop-down menu, select your desired date-and-time condition:

    1. in the future

    2. in the past

    3. now

  7. In Mode, choose how you want to modify your current values if the date attribute meets the desired date-and-time condition:

    1. assign overwrites the current value with the value of the attribute chosen in Step 8.

    2. append adds the value of the attribute chosen in Step 8 at the end of the current value.

    3. prepend adds the value of the attribute chosen in Step 8 at the beginning of the current value.

  8. In Column, select the attribute that stores the values you want to assign, append, or prepend.

  9. Select Save.

Add a temporary text or discount based on a date

You can use the Limited Time Only rule box to change a value in an attribute temporarily. This rule box can change a value by applying a discount, assigning a new value, and appending or prepending a string to a value. You can set the timeframe when the platform should change the values manually or by using dates stored in other attributes.

  1. Go to Dataflow and choose the needed export in the drop-down menu on the left.

  2. Select the needed attribute:

    1. To add a rule box between the import and intermediate stages, select an attribute in the intermediate stage.

    2. To add a rule box between the intermediate and export stages, select an attribute in the export stage.

  3. Search for Limited Time Only in the drop-down menu Select an Option and add the rule box.

    limited_time_only.png
  4. Use one of the following options to define the start date for applying the changes to your attribute:

    Note

    For both options, your dates need to be in the format Y-m-d. For example, 2023-01-31.

    1. Select a relevant attribute that stores the needed date in Start Date via Column.

      If you add your rule box in the intermediate stage, only import-stage attributes are available in this drop-down menu. If you add it in the export stage, only intermediate-stage attributes are available.

    2. Enter the date manually in set Start Date.

  5. Use one of the following options to define the end date for applying the changes to your attribute:

    Note

    For both options, your dates need to be in the format Y-m-d. For example, 2023-01-31.

    1. Select a relevant attribute that stores the needed date in End Date via Column.

      If you add your rule box in the intermediate stage, only import-stage attributes are available in this drop-down menu. If you add it in the export stage, only intermediate-stage attributes are available.

    2. Enter the date manually in set End Date.

  6. Choose how you want to change the values in your attribute:

    1. If you want to add certain text to your attribute, enter the desired text in Text and choose how you want the rule box to modify your current value with this text in Mode:

      1. assign overwrites the value with the desired text completely.

      2. append adds the desired text at the end of the value.

      3. prepend adds the desired text at the beginning of the value.

    2. If you want to add a discount to your attribute, enter the discounted amount in Discount. The expected input format is a number. No need to add the percent symbol (%).

  7. Select Save.