Customizing Text Based on Time of Day

Interactive video content offers a unique opportunity to engage viewers with personalized experiences. One creative approach to achieve this is by customizing text layers within your video based on the time of day a viewer is watching. This dynamic personalization can make your content feel more relevant and engaging to your audience.

Here's how you can implement a dynamic greeting in your video content that changes based on the current time of day:

  1. Select the Text Connector: Choose the text connector for the layer you wish to personalize within your video.

  2. Code Integration: Insert the following JavaScript code into the text connector's script area:

const getTimeOfDay = (() => {
  const hourNow = (new Date()).getHours();
  if (hourNow < 5) { return " evening"; } // Night and evening before 5 AM
  if (hourNow < 12) { return " morning"; } // Before noon
  if (hourNow < 18) { return " afternoon"; } // Before 6 PM
  return " evening"; // Back to evening after 6 PM
});

return "Good" + getTimeOfDay();

This code snippet determines the current hour of the day and dynamically updates the text to display a greeting appropriate to the time of day—morning, afternoon, or evening.

How to Use This Feature:

  • Engage Your Audience: Incorporate this dynamic greeting at the beginning of your video or in specific sections where you want to personalize the viewer's experience. For example, you might start your video with "Good morning" or "Good evening," depending on when it's being watched.

  • Experiment with Text and Timing: Feel free to adjust the time intervals and the text displayed to fit the context of your video content better. For instance, if your target audience is more likely to watch your content late at night, you might add a specific greeting for late-night viewers.

By personalizing your video content based on the time of day, you create a more engaging and memorable experience for your viewers. This technique can be particularly effective for daily greetings, promotional messages, or any content where you want to add a personal touch based on when your audience is watching.