Date formats with leading zeros

Hello

I have a grid that displays dates like this:


The above dates  (July  dates) are en-AU  format and are controlled by setting the culture in program.cs. The grid column itself has Format="d".

So 

- when the culture is en-AU then I get (say) 9/7/2021 (i.e 9th July)

- when the culture is en-US then I get 7/9/2021  (i.e 9th July)

What I am trying to do is force all my dates to have leading zeros....so what I am looking for is:

- when the culture is en-AU then I would get 09/07/2021 

- when the culture is en-US then I would get 07/09/2021 

I can format the date directly in the column, i.e "dd/MM/yyyy" but then this does not play nicely with the culture setting.

Any ideas

Thank you















3 Replies

RS Renjith Singh Rajendran Syncfusion Team February 10, 2022 01:45 PM UTC

Hi Richard, 
 
Greetings from Syncfusion support. 
 
Query : I can format the date directly in the column, i.e "dd/MM/yyyy" but then this does not play nicely with the culture setting. 
We checked this by applying “dd/MM/yyyy” format for date column in Grid. We could display the date values in expected format. We are attaching the sample created with en-US localization for your reference. 
 
Please refer the screenshot below, 
 
 
 
We are not clear about the problem you are facing when applying “dd/MM/yyyy” format. Kindly refer the above sample and check this from your side. If you are facing difficulties then the following details would be helpful for us to proceed further. 
 
  1. Share a simple issue reproducing sample based on your scenario for us to validate.
  2. Share the detailed explanation of the problem you are facing.
  3. Share the en-AU resx file you are using in your application.
  4. Share a video demo showing the replication of the problem  you are facing.
 
The provided information will help us analyze the problem, and provide you a solution as early as possible. 
 
References :  
 
Regards, 
Renjith R 



DI Ditchford February 13, 2022 12:03 PM UTC

Hey

Thanks for the information.  My question was simply if there is a way to ensure dates for all cultures have leading zeros without specifying it directly in the format of the grid column.


So if the culture was en-US then you would see "02/09/2022" , not "2/9/2022"   (February 9th)

if the culture was en-GB then you would see "09/02/2022", not "9/2/2022"  (February 9th)


If you specify Format="d" then it handles the culture change, but without the leading zero.


I think the answer is no, so I have simply set the dateformat when setting the culture and then specifiy the Format like this:

Format="@MyAppStateService.MyCultureDateFormat"


Thanks for your help












RS Renjith Singh Rajendran Syncfusion Team February 14, 2022 10:13 AM UTC

Hi Richard, 
 
Thanks for your update. We are glad to hear that you have achieved this requirement by applying Format. Please get back to us if you need further assistance. 
 
Regards, 
Renjith R 


Loader.
Up arrow icon