Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dateformat and C# MVC - Trying to help... #387

Open
rhousham opened this issue Jan 18, 2023 · 3 comments
Open

Dateformat and C# MVC - Trying to help... #387

rhousham opened this issue Jan 18, 2023 · 3 comments

Comments

@rhousham
Copy link

rhousham commented Jan 18, 2023

Hi unsure where this belongs, however if you are creating a new C# MVC application. In previous incarations of the datepicker the MMM format has returned back 3 digit months. This is still the case apart from September which returns back Sept.

C# Doesn't - out of the box - recognise this as a valid month/date.
At least not in the Uk - great britain.

The fix - enter

<system.web>
`    <globalization uiCulture="en" culture="en-GB"/>`
</system.web>

In the web.config.

This seems to be down to the Intl.DateTimeFormat library and less tempusdominus - but thought I would save someone a job if they find this.

@rhousham rhousham reopened this Jan 18, 2023
@rhousham
Copy link
Author

Nope tell a lie - that didn't work...

@rhousham
Copy link
Author

Seems like the fix is doing
localization: {
locale: 'en-US',//fix to make sure september is shortended to sep - rather than sept - which c# doesn't understand
format: 'dd-MMM-yyyy'
},

In the config

@rhousham
Copy link
Author

Or update the c# Global.asax.cs and add

 System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("en-GB");
            System.Globalization.CultureInfo.DefaultThreadCurrentCulture.DateTimeFormat.AbbreviatedMonthNames  = new string[] {
                "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec", ""
            };

It looks like basically there is a difference between c# microsoft and the javascript short months - hence causing issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant