是否可以更改日期时间选择器中的日期格式?

时间:2022-09-26 11:18:29

I found a great date time picker based on jQuery-ui http://trentrichardson.com/examples/timepicker/, but suddenly realized that i can't modify date format... Tried something like this:

我发现了一个很棒的日期时间选择器,它基于jQuery-ui http://trentrichardson.com/examples/timepicker/,但是突然发现我不能修改日期格式…过是这样的:

jQuery('.datetimepicker').datetimepicker({
        timeFormat: 'HH:mm'
    }).formatDate('yy-mm-dd');

Can someone show an example on it?

有人能举个例子吗?

7 个解决方案

#1


5  

You can use the code:

你可使用守则:

jQuery('.datetimepicker')
    .datetimepicker({ 
        dateFormat: 'yy-mm-dd', 
        timeFormat: 'HH:mm' 
     });

#2


2  

Try this:

试试这个:

This will set the date format to "yy-mm-dd"

这将把日期格式设置为“yy-mm-dd”

 $.datepicker._defaults.dateFormat = "yy-mm-dd";

#3


2  

Yes it is possible, have a look at the dateFormat option in the API Documentation for the datepicker

是的,这是可能的,请查看dateFormat选项在API文档中为datepicker。

This will work,

这将工作,

jQuery('.datetimepicker').datetimepicker({
        timeFormat: 'HH:mm',
        dateFormat: "yy-mm-dd"
});

#4


1  

yes it is possible to format the date. Refer the link given in this API

是的,格式化日期是可能的。引用此API中给出的链接

$.datepicker.formatTime(format, timeObj, options)

Refer the Formatting tab in this url. At the bottom of page u find the option to format a date

请在此url中引用格式选项卡。在u页底部找到格式化日期的选项

#5


0  

Try this :

试试这个:

jQuery('.datetimepicker').datetimepicker({ dateFormat: "D MM d, yy" });

jQuery(“.datetimepicker”)。datetimepicker({dateFormat:“D MM D, yy”});

and see this for more documentation : http://trentrichardson.com/examples/timepicker/#tp-formatting

更多的文档请参阅:http://trentrichardson.com/examples/timepicker/#tp-formatting

#6


0  

POSSIBLE, heres an example link. extracting from this example souldnt be a problem i guess :)

可能,这里有一个例子链接。从这个例子中提取的souldnt是一个问题:

http://jqueryui.com/resources/demos/datepicker/date-formats.html

http://jqueryui.com/resources/demos/datepicker/date-formats.html

#7


0  

Just to add that none of the above worked for me, but the following did:

我想说的是,以上这些方法对我都不起作用,但下面的方法却起了作用:

$(".datetimepicker").DateTimePicker({
    dateFormat: 'yyyy-mm-dd'
});

Regards

问候

Liam

利亚姆

#1


5  

You can use the code:

你可使用守则:

jQuery('.datetimepicker')
    .datetimepicker({ 
        dateFormat: 'yy-mm-dd', 
        timeFormat: 'HH:mm' 
     });

#2


2  

Try this:

试试这个:

This will set the date format to "yy-mm-dd"

这将把日期格式设置为“yy-mm-dd”

 $.datepicker._defaults.dateFormat = "yy-mm-dd";

#3


2  

Yes it is possible, have a look at the dateFormat option in the API Documentation for the datepicker

是的,这是可能的,请查看dateFormat选项在API文档中为datepicker。

This will work,

这将工作,

jQuery('.datetimepicker').datetimepicker({
        timeFormat: 'HH:mm',
        dateFormat: "yy-mm-dd"
});

#4


1  

yes it is possible to format the date. Refer the link given in this API

是的,格式化日期是可能的。引用此API中给出的链接

$.datepicker.formatTime(format, timeObj, options)

Refer the Formatting tab in this url. At the bottom of page u find the option to format a date

请在此url中引用格式选项卡。在u页底部找到格式化日期的选项

#5


0  

Try this :

试试这个:

jQuery('.datetimepicker').datetimepicker({ dateFormat: "D MM d, yy" });

jQuery(“.datetimepicker”)。datetimepicker({dateFormat:“D MM D, yy”});

and see this for more documentation : http://trentrichardson.com/examples/timepicker/#tp-formatting

更多的文档请参阅:http://trentrichardson.com/examples/timepicker/#tp-formatting

#6


0  

POSSIBLE, heres an example link. extracting from this example souldnt be a problem i guess :)

可能,这里有一个例子链接。从这个例子中提取的souldnt是一个问题:

http://jqueryui.com/resources/demos/datepicker/date-formats.html

http://jqueryui.com/resources/demos/datepicker/date-formats.html

#7


0  

Just to add that none of the above worked for me, but the following did:

我想说的是,以上这些方法对我都不起作用,但下面的方法却起了作用:

$(".datetimepicker").DateTimePicker({
    dateFormat: 'yyyy-mm-dd'
});

Regards

问候

Liam

利亚姆