Dates - Do you keep date formatting consistent?

Last updated by Brady Stroud [SSW] 10 months ago.See history

Date formats should always be kept consistent across applications. More importantly, they should be kept consistent with the operating system's regional settings, otherwise this will cause significant confusion for users.

operatingsystem language setting
Figure: Operating System's Regional Settings

Figure: Bad example - Screens with inconsistent date formats

Figure: Good example - Screens with consistent date formats

The best way to do this in your code is to grab the culture information from the application thread and use it to automatically format your Datetime data type. Do not use hard coded datetime formatting strings unless it's absolutely necessary.

startTimeTextBox.Text = resultResults.StartTime.ToString("dd/MM/yyyy hh:mm:ss");

Figure: Bad example - Using hard coded formatting string

'VB.NET
'Initial CultureInfo settings for the application
Public initialCulture As CultureInfo
...

...
txtDateCreate.Text = CType(txtDateCreate.Tag, System.DateTime).ToString(initialCulture.DateTimeFormat)

Figure: Good example - Using culture info to format datetime

Browser language settings

It is required to set web browser language to English (Australia) after modifying the computer reginal and language settings. This ensures proper formatting and compatibility, particularly when downloading web pages or accessing specific web content.

For example, Power BI is date format agnostic and will honor the setting in your browser. If your browser language is set to US English, it may cause date formatting issues.

PowerBI wrong date format
Figure: Date format incorrect due to unmodified web page language settings

Go to Browser Settings | Language | Select English (Australia) as the top priority language:

browser language setting
Figure: Set English (Australia) as the top priority in the browser language settings

For more information, refer to make sure all software uses English rule.


We open source.Loving SSW Rules? Star us on GitHub. Star
Stand by... we're migrating this site to TinaCMS