Skip to content

Instantly share code, notes, and snippets.

@elindoorn
Last active November 30, 2015 15:55
Show Gist options
  • Save elindoorn/97d443ffaacd9bddc22a to your computer and use it in GitHub Desktop.
Save elindoorn/97d443ffaacd9bddc22a to your computer and use it in GitHub Desktop.
Format date in template (Liferay 6.2)
#set ($date = $dateTool.toDate("EEE, dd MMM yyyy hh:mm:ss Z", $reserved-article-modified-date.getData(), $localeUtil.getDefault()))
#set ($timeZone = $timeZoneUtil.getTimeZone($user.getTimeZoneId()))
#set ($dateTimeFormat = "EEEE d MMMM yyyy")
#set ($modifiedDate = $dateTool.format($dateTimeFormat, $date, $locale, $timeZone))
$modifiedDate
Alternative to get a language specific format:
#set ($dateTimeFormat = $languageUtil.get($locale, "project-date-format"))
Then define project-data-format in the language files
Dutch: project-date-format=EEEE d MMMM yyyy
English: project-date-format=EEEE, MMMM d, yyyy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment