Display Friendly Date Interval

Last Updated: Jul 27, 2021
documentation for the dotCMS Content Management System

Return different messages depending the input date. The input date must be before the current date.

Macro Overview:

Syntax:

$dateviewapi.friendly(date)

Arguments:

  • date (date/required)
    Date to diff with the current date.

Optional Parameters:


Usage:

Use this to show the difference date and time between a string date (before the current date) and the current date.
Examples:

Example 1: A simple example using the required fields

Wed, 02 Apr 2008 16:23:14 +0000<br>
  #set ($tempDate = $UtilMethods.parseDate("Wed, 02 Apr 2008 16:23:14 +0000", "EEE, dd MMM yyyy HH:mm:ss +SSSS"))
  Result Message: $dateviewapi.friendly($tempDate)<br>
  
  Assuming that current date is: Fri, 02 May 2008 17:20:00 - The output will be: Wed., April 2, 4:23 PM
    

Example 2: An example showing how to include one or more of the optional parameters

Sat, 26 Apr 2008 16:23:14 +0000<br>
  #set ($tempDate = $UtilMethods.parseDate("Sat, 26 Apr 2008 16:23:14 +0000", "EEE, dd MMM yyyy HH:mm:ss +SSSS"))
  Result Message: $dateviewapi.friendly($tempDate)<br>
  
  Assuming that current date is: Fri, 02 May 2008 17:20:00 - The output will be: Saturday at 4:23 PM
    

Example 3: An example showing how to include one or more of the optional parameters

Thu, 01 May 2008 16:23:14 +0000<br>
  
  #set ($tempDate = $UtilMethods.parseDate("Thu, 01 May 2008 16:23:14 +0000", "EEE, dd MMM yyyy HH:mm:ss +SSSS"))
  Result Message: $dateviewapi.friendly($tempDate)<br>
  
  Assuming that current date is: Fri, 02 May 2008 17:20:00 - The output will be: Yesterday at 4:23 PM
    

Example 4: An example showing how to include one or more of the optional parameters

Fri, 02 May 2008 14:20:00 +0000<br>
  #set ($tempDate = $UtilMethods.parseDate("Fri, 02 May 2008 14:20:00 +0000", "EEE, dd MMM yyyy HH:mm:ss +SSSS"))
  Result Message: $dateviewapi.friendly($tempDate)<br>
  
  Assuming that current date is: Fri, 02 Apr 2008 17:20:00 - The output will be: 3 hour(s) ago

Example 5: An example showing how to include one or more of the optional parameters

Fri, 02 May 2008 17:10:00 +0000<br>
  #set ($tempDate = $UtilMethods.parseDate("Fri, 02 May 2008 17:10:00 +0000", "EEE, dd MMM yyyy HH:mm:ss +SSSS"))
  Result Message: $dateviewapi.friendly($tempDate)<br>
  
    Assuming that current date is: Fri, 02 May 2008 17:20:00 - The output will be: 10 minute(s) ago
    


On this page

×

We Dig Feedback

Selected excerpt:

×