Timestamp attributes are now supported in Vercel Flags
Vercel Flags now supports timestamp attributes for entities, which represent the users, teams, devices, or requests evaluated by a flag.
Use timestamp attributes to show a campaign page only between two dates, run a Black Friday promotion, or target users who registered before a cutoff.
Configure a timestamp attribute
You can configure timestamp attributes in the dashboard or via the CLI.
In the Vercel dashboard, open Flags, select Entities, and create or select an entity. Add an attribute and set its data type to timestamp.
Or define the attribute with the CLI:
Whether you configure the attribute in the dashboard or CLI, your application must provide its value when evaluating a flag. The entity and attribute names must match your configuration, and the value must be a Unix epoch timestamp in milliseconds.
This Flags SDK example passes the current time as system.time. Date.now() returns the required value in milliseconds. Keeping it inside dedupe() ensures that every flag evaluated during the same request uses the same time:
Add a targeting rule
In the dashboard, open the flag and add a targeting rule using the timestamp attribute. The rule compares the value from your application with a date and time you choose.
Rules support is after, is at or after, is before, and is at or before. The date and time picker uses your local timezone.
To add a time-based targeting rule with the CLI, use after, at-or-after, before, or at-or-before:
Learn how to provide entities in code and release a flag at a specific time, or read the Flags documentation.