Date Format based on browser locale

2 posts, 1 answers
  1. Alex
    Alex avatar
    25 posts
    Member since:
    Oct 2011

    Posted 23 May 2019 Link to this post

    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?

  2. Answer
    Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    1263 posts

    Posted 27 May 2019 Link to this post

    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.
Back to Top