This is a migrated thread and some comments may be shown as answers.

Date Format based on browser locale

1 Answer 973 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 23 May 2019, 11:22 AM

I'm trying to use a DatePicker, and I would like it to show the selected date in a format appropriate for the browser locale (e.g. as I'm in UK and my browser is set to UK English I'd like the DatePicker to show 23rd May 2019 as 23/05/2019).

I've been trying to read through the globalization documentation but I'm getting a bit lost. Can you point me in the right direction or share an example that does what I'm asking?

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimiter Topalov
Telerik team
answered on 27 May 2019, 08:08 AM
Hi Alex,

The DatePicker will by default display the formatted Date value, based on the locale currently loaded in the application and/or the format, explicitly provided to the format option:

https://www.telerik.com/kendo-angular-ui/components/dateinputs/datepicker/formats/

The default locale in the Angular applications is en-us, but you can load another one as demonstrated in the following section of our documentation:

https://www.telerik.com/kendo-angular-ui/components/globalization/internationalization/loading-data/

... or load locale data on demand and/or change the locale dynamically:

https://www.telerik.com/kendo-angular-ui/components/globalization/internationalization/loading-data/#toc-loading-locale-data-on-demand

https://www.telerik.com/kendo-angular-ui/components/globalization/internationalization/locale-changes/

Here is an example of formatting the date in the DatePicker using a preset format:

https://stackblitz.com/edit/angular-4ahfy8?file=app/app.component.ts

... and one that demonstrates loading the en-GB locale, and using the default date formatting for this locale:

https://stackblitz.com/edit/angular-fe9fk2-7qcken?file=app/app.component.ts

I hope this helps.

Regards,
Dimiter Topalov
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DatePicker
Asked by
Alex
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or