0

My application is in Asp.Net MVC3 coded in C#.Net. Off Late i'm facing a issue related with the date format of the client machine.

Two Scenarios :

  1. If the solution is published on my company's server, then in that scenario i don't need to worry regarding the format of the date and the issues related to it, as i know in which format is my server / machine's date is set.

My Issue

  1. If i have to publish the content on any customers machine, then at the time of installation i can probably set the date format of the customer's machine as per my applications requirement.

    But one such scenario has been encountered and that is, if the user of the customer machine changes the date format then we get the problem in posting the data to the controller or any other Json method.

Example:1

$("#My_Control").load("/../My_Controller/My_Method", { My_Variable: $("#My_DatePicker_value").val()}, function () { });

Above is my Jquery code which passes a certain date to one of my method, but if the date format at the customer machine does not matches with the format in my jquery code then it is not visiting the Json method.

Example:2 (Sample Code)

[HttpPost]
public ActionResult Create(MyEntity Entity_Object)
{
     return View()
}

In the above scenario, if the date format of the posted date and the format of the customer's machine does not match then the Entity_Object is showing that values as NULL

Following are the links i have gone through:

Date Formatting Link 1

Date Formatting Link 2

Date Formatting Link 3

Suggest if it is possible and how.

Community
  • 1
  • 1
Sam M
  • 1,077
  • 2
  • 20
  • 42

1 Answers1

0

I don't have knowledge about mvc. But I think by the setting of web.config file you can solve it.

Change in web.config

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

After changing in web.config file you will get date format in dd/MM/yyyyat all the client machine.

In my case i had solved this problem using this code but i am not sure it will work or not in your case.i was using asp.net 4.0

I hope it may help you.

Govinda Rajbhar
  • 2,926
  • 6
  • 37
  • 62