Knowledgebase

Formatting Values for Display Print

  • phplaravel, troubleshooting, guide, howto, solution, zillionkinghost, hosting, support
  • 0

Presentation of data.

WHAT TO FORMAT CONSISTENTLY

Money Dates and times Numbers Quantities and units

WHERE TO DEFINE THE FORMATTING

In one place, reused.

WHY

Otherwise the same value appears differently on different pages.

WHAT TO USE FOR MONEY

A consistent format including the currency, with fixed decimal places.

WHAT TO BE CAREFUL WITH

Storing money as decimals and formatting at display, rather than rounding as you go.

WHAT TO USE FOR DATES

A format your users read naturally, stated unambiguously.

WHY THAT MATTERS

Numeric dates are ambiguous between regions.

Including the month name removes the ambiguity.

WHAT TO SHOW FOR RECENT TIMES

Relative descriptions, where helpful, with the exact value available.

WHAT TO AVOID

Relative times for anything requiring precision Different formats in different parts of the application

WHAT TO CENTRALISE

Formatting helpers or accessors on models.

WHAT TO TEST

Very large values, zero, and negative values.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot