0

I'm trying to implement the jquery datepicker and datetimepicker into 1 script but standard the date is US formatted. (should be DD-MM-YY) I cannot get the javascriptcode working, what's wrong?

 <script type="text/javascript" > 
  $(document).ready(function() {

    function tijd(){ 
    $('#datepicker').datetimepicker({
        timeFormat: 'h:m', 
        stepHour: 1,
        stepMinute: 15
        });
    }
    function datum(){ 
    $('#datepicker').datepicker({ 
        dateFormat: 'dd-mm-yy' 
        });
    }
  });
  </script>
0

1 Answer 1

0

If your looking for a date like "07-09-11" try something like

dateFormat: 'dd-mm-y' 

if your looking for a date like "7-9-11" then then try,

dateFormat: 'd-m-y'

But whatever the format your looking for your going to need to use the formats listed here: http://docs.jquery.com/UI/Datepicker/formatDate

And if you want to customize the dates look you might do something like

            dateFormat: 'MM yy',
            create: function (input, inst) {
                var datestr = $(this).val();
                var month = datestr.substring(0, datestr.indexOf("/")) - 1;
                var temp = datestr.substring(datestr.indexOf("/") + 1, datestr.length);
                var year = temp.substring(temp.indexOf("/") + 1, temp.indexOf("/") + 5);
                $(this).datepicker('setDate', new Date(year, month, 1));
            }

This gives you MONTH YEAR like "SEPTEMBER 2011"

But my guess is you have too many 'y' in your format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.