Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

date format dd/MM/yyyy not working in asp.net mvc 5

I'm developing an asp.net mvc 5 application, in which I'm trying to set a validation for dd/MM/yyyy format, I've been struggling a lot to find an appropriate solution but no success, what I want it to accept:

24/01/2016

but it displays validation message as :

The field JoiningDate must be a date.

Here is what I've tried :

[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime JoiningDate { get; set; }

Also, I want it to display the date in dd/MM/yyyy format everywhere at the user's end but this is a second part of my question, firstly, it should at least allow a valid date input. I'm stuck on this one, any help will be deeply appreciated, I've searched all over, but I'm not being able to get to the point, Thanks In Advance :)

like image 670
Bilal Ahmed Avatar asked Dec 11 '22 17:12

Bilal Ahmed


1 Answers

The easiest way, I found was put in the web.config the code below

 <system.web>
    <globalization uiCulture="en" culture="en-GB"/>
</system.web>
like image 61
Josue Morales Avatar answered Jan 08 '23 11:01

Josue Morales