1

I need to show date with day and month only, but if I set dateFormat: "d MM", I can not change year. It's always 2012. For example: http://jsfiddle.net/v2vcV/. Just try change date for January 2013 and reopen calendar, year will be still 2012.

Kohver
  • 356
  • 5
  • 13
  • If the year isn't being used, what difference does it make which year it shows in the datepicker? – Barmar Dec 17 '12 at 07:12
  • Because I want to get correctly year using `$('#datepicker').datepicker('getDate')` – Kohver Dec 17 '12 at 07:18
  • You could probably do some chicanery with [`altField`](http://api.jqueryui.com/datepicker/#option-altField) and [`altFormat`](http://api.jqueryui.com/datepicker/#option-altFormat). – mu is too short Dec 17 '12 at 07:18
  • @muistooshort so far it's the best solution. Will focus on that — http://jsfiddle.net/Kohver/v2vcV/22/ – Kohver Dec 17 '12 at 08:21

2 Answers2

0

I have made a small change but it gives you Year also, indeed it removes the bug you were facing

Check Here

using this resolves problem $( "#datepicker" ).datepicker({dateFormat: "dd MM yy"});

You can remove that year logically afterwards when the date is set.

I have made all edit changes and it works great now..Check Here

Enjoy.. :)

ameya rote
  • 1,116
  • 1
  • 9
  • 13
0

This can help you. HTML

<p>Date: <input type="text" style="visibility:hidden; width:0px" id="datepicker2"><input type="text" id="datepicker"></p>

JS

$(function() {
    $("#datepicker").focus(function(){
        $("#datepicker2").focus();
    });
    $("#datepicker2").datepicker({dateFormat: "dd MM yy",
    onSelect:function(date){
        $("#datepicker").val(date.substring(0,date.length-4));
        }
    });
});

Any way this is not the perfect way but can help what you want(as a illusion). if you want the exact date with year you can get it from datepicker2 textbox.

Sudhanshu Yadav
  • 2,323
  • 18
  • 18