jQuery Bootstrap datetimepicker 中的日期格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24926916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 02:41:13  来源:igfitidea点击:

Date format in Bootstrap datetimepicker

jquerytwitter-bootstrapdatetimepicker

提问by rb vishnu

I am just working on Bootstrap datetimepicker, and I am done that. A small problem is there, I tried to change the selected date format and failed. How can I fix this?

我只是在 Bootstrap datetimepicker上工作,我已经完成了。有一个小问题,我尝试更改所选日期格式并失败。我怎样才能解决这个问题?

This is my code:

这是我的代码:

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

This is my jsfiddle link http://jsfiddle.net/vishnur15/8tsCt/2/

这是我的 jsfiddle 链接http://jsfiddle.net/vishnur15/8tsCt/2/

回答by Se0ng11

check this jsfiddle

检查这个jsfiddle

http://jsfiddle.net/8tsCt/4/--not working due to reference link broken

http://jsfiddle.net/8tsCt/4/ --由于参考链接损坏而无法工作

latest version as per 2017

2017年最新版本

http://jsfiddle.net/8tsCt/166/

http://jsfiddle.net/8tsCt/166/

format must be

格式必须是

$('.datepicker').datetimepicker({
    format: 'DD-MM-YYYY HH:mm:ss'
});

回答by SuperNova

Please use data-date-format="DD-MM-YYYY HH:mm:ss"inside the input tag.

data-date-format="DD-MM-YYYY HH:mm:ss"在输入标签内使用。

<input data-date-format="DD-MM-YYYY HH:mm:ss" type="text" />

See this. https://jsfiddle.net/h0jk6oq4/

看到这个。https://jsfiddle.net/h0jk6oq4/

回答by Mike S

$('.datepicker').datetimepicker({
    format: 'dd.mm.yyyy HH:ii'
});

回答by Ramzan Zafar

If you are using boot strap then there is no need to update the jQuery function just do it like

如果您使用的是引导带,则无需更新 jQuery 函数,只需像这样

<input data-format="dd/MM/yyyy hh:mm:ss" type="text"></input>

Hope this will help

希望这会有所帮助