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
    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:

    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:

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

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

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

    I hope this helps.

    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