ANS-0974 · PRINTING, PDF & EMAIL TEMPLATES

How to Format Date Output in NetSuite Advanced PDF/HTML Templates Using Freemarker?

Learn to leverage Freemarker built-in functions to display dates and times in various custom formats within your NetSuite Advanced PDF documents.

Short answer

NetSuite Advanced PDF/HTML Templates utilize Freemarker built-in functions for date formatting. By applying the ?string function to a date variable, users can specify desired output patterns using standard date and time format specifiers, ensuring consistent and customized date displays on printed documents.

Scenario

Users often need to display dates and times in specific formats on NetSuite Advanced PDF/HTML Templates, such as invoices, sales orders, or purchase orders. The default date output may not always align with regional standards or specific document requirements, necessitating customization.

Solution

NetSuite Advanced PDF/HTML Templates leverage Freemarker built-in functions to customize date and time output. To format a date, the ?string function is applied to the date variable, followed by a pattern string that defines the desired format.The general syntax for formatting a date is:

{yourDate?string("yyyy/MM/dd")}

Here are examples demonstrating various date and time formatting patterns:

{lastUpdated?string("yyyy-MM-dd HH:mm:ss zzzz")}
{lastUpdated?string("EEE, MMM d, ''yy")}
{lastUpdated?string("EEEE, MMMM dd, yyyy, hh:mm:ss a '('zzz')'")}

These examples illustrate how to achieve different date and time representations, from full timestamps with time zones to abbreviated day and month formats.

Expert NetSuite Support

Need help with this NetSuite issue?

Printing, PDF & Email Templates consulting and configuration support

Talk to a consultant