dotcms documentation wiki

2
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, 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"))

Upload: perico-palotes

Post on 12-Mar-2015

71 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DotCMS Documentation Wiki

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

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