在jquery datepicker中从24小时格式化时间删除冒号

时间:2016-09-30 17:08:48

标签: javascript jquery datetimepicker

我需要解决一段时间一直困扰我的错误列表但在Google中找不到任何可靠内容的问题。我想要的只是从时间中删除冒号,以便我可以在真正的军事时间显示它。

所以,这是错误的 - > 13:25 这是对的 - > 1325小时

我在Jquery UI库中使用Jquery Date Picker,在here使用datetimepicker-addon.js

HTML

<div class="container">
    <input type="text" name="my_date" id="my_date" value="" />
</div>  

JS

$(function(){   
    $("#my_date").datetimepicker({
       timeFormat: "HH:mm 'hrs'",
       showButtonPanel: false
    });
});

这是一个方便的花花公子 CODEPEN

我很感激帮助

1 个答案:

答案 0 :(得分:2)

timeFormat datetimepicker删除冒号

$(function(){
	// when the document has loaded 
	// attach the datetimepicker
	$("#my_date").datetimepicker({
		timeFormat: "HHmm 'hrs'",
		showButtonPanel: false
	});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-timepicker-addon/1.6.3/jquery-ui-sliderAccess.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-timepicker-addon/1.6.3/jquery-ui-timepicker-addon.js'></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-timepicker-addon/1.6.3/jquery-ui-timepicker-addon.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
<div class="container">
	<input type="text" name="my_date" id="my_date" value="" />
</div>