3

I am having problem with input type=date, Currently it is showing MM/DD/YYYY format in india but when my end user(IN UK OR US) choose date from this date picker that time it is showing in DD/MM/YYYY format so how i can resolve it?

I can't use salesforce date picker here i have used input type=date as per my requirement.

I want is that i always need to select date in MM/DD/YYYY format from anywhere, so How i can achive it?

Thanks in advance.

2 Answers 2

2

<input type="date" /> has really bad cross browser support. In my experience, some browsers use different date formats altogether.

I'd really recommend using jQuery UI's Datepicker for this which will give you control over what format is inputted. If you include:

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>

And use:

$('.datepicker').datepicker({ dateFormat: 'mm/dd/yy' }).val();

Naming any input types with a class="datepicker" parameter, this should work.

This should display a good datepicker that will input the date in the format you want. You may need to use some regex to ensure the correct format gets sent to the server, however.

2
  • But my problem in same browser "Chrome".
    – user9839
    Oct 15, 2015 at 12:45
  • Chrome might adjust date format depending on the region, I'm not sure. Either way, using jQuery UI's datepicker will ensure you get the same format regardless of region.
    – Dan Jones
    Oct 15, 2015 at 12:47
0

has really bad cross browser support. In my experience, some browsers use different date formats altogether.

I'd really recommend using jQuery UI's Datepicker for this which will give you control over what format is inputted. If

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .