开发者

datepicker and datetimepicker EU format?

开发者 https://www.devze.com 2023-04-11 04:57 出处:网络
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'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({ 
    开发者_JAVA百科    dateFormat: 'dd-mm-yy' 
        });
    }
  });
  </script>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消