dotcms documentation wiki
TRANSCRIPT
![Page 1: DotCMS Documentation Wiki](https://reader030.vdocuments.net/reader030/viewer/2022013118/550166854a7959ac638b4f1b/html5/thumbnails/1.jpg)
Date Formatting
Return diferent 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, ddMMM 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, ddMMM yyyy HH:mm:ss +SSSS"))
![Page 2: DotCMS Documentation Wiki](https://reader030.vdocuments.net/reader030/viewer/2022013118/550166854a7959ac638b4f1b/html5/thumbnails/2.jpg)
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, ddMMM 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, ddMMM 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: 3hour(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, ddMMM 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: 10minute(s) ago