Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What layer should a date be formatted?

What layer of a system should a date be formatted? Should the date be formatted when it is selected from the database (data layer) or should it be formatted at the presentation layer?
I am thinking that the formatting is a visual preference so I would tend to put it as close to the presentation layer as possible.

Where do you store the format string for the preferred date?

like image 1000
CSharpAtl Avatar asked Dec 29 '22 02:12

CSharpAtl


1 Answers

The date (also like money and other numerical formats) should be formatted at the presentation layer. The format string would typically be part of the locale information. I'd suggest reading up on internationalization (also known as i8n). Given your moniker is C#'ish here is one place to look:

Microsoft .Net Internationalization

like image 109
Peter M Avatar answered Jan 05 '23 16:01

Peter M