Ask AI
Skip to main content

Relative date

Function: Relative date

This function helps you quickly understand how recent or far away a specific date is by converting it into a user-friendly phrase like "yesterday," "tomorrow," or "2 months ago." It's perfect for displaying dates in a more natural and readable way in your applications.

Input

  • Date to check (Type: DATE, Required): The specific date you want to convert into a relative phrase. This input is essential for the function to work.

Output

  • Result (Type: STRING): The relative date as a text phrase (e.g., "today", "yesterday", "in 3 days", "2 months ago").

Execution Flow

Real-Life Examples

Here are some examples of how you can use the "Relative date" function:

Example 1: Displaying a recent activity date

Imagine you have a list of recent activities, and you want to show when each activity occurred in an easy-to-read format.

  • Inputs:
    • Date to check: 2023-10-26 (assuming today is 2023-10-27)
  • Result: The application displays "yesterday" next to the activity.

Example 2: Showing an upcoming event's proximity

You're building an event management app and want to highlight how soon an event is happening.

  • Inputs:
    • Date to check: 2023-10-29 (assuming today is 2023-10-27)
  • Result: The application displays "in 2 days" next to the event.

Example 3: Summarizing a document's last modification date

For a document management system, you want to show when a document was last updated without displaying the full date and time.

  • Inputs:
    • Date to check: 2023-05-15 (assuming today is 2023-10-27)
  • Result: The application displays "5 months ago" as the last modified date.