我正在用Django創建一個運動應用程序。我需要顯示一個倒數列表,這些倒數到達那些比賽的確切時間。使用Django的Javascript日期格式
一切工作都會發現,除了倒數到達比賽的那一天,而不是幾小時和幾分鐘。例如,如果比賽開始時間爲晚上9點的2天,倒計時將在比賽當天的午夜停止。所以它不會到晚上9點。
這裏是我的代碼:
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" src="http://keith-wood.name/js/jquery.countdown.js"> </script>
</head>
<body>
<div style="float:left">
{% for match in matches %}
<div>
<p>{{ match }}</p>
<p> {{match.real_start}} <p>
<a href="{{ match.get_absolute_url_grille }}">Go</a>
<div class="match_countdown" data-date="{{ match.real_start|date:'M j, Y'}}"></div>
</div>
{% endfor %}
</div>
</br></br>
<script>
$('.match_countdown').each(function() {
var self = $(this),
date_string = self.attr('data-date'),
date = new Date(date_string);
self.countdown({until: date});
});
</script>
</body>
「real_start」是我的DateTime 我想這個問題是關於日期格式「MĴ,Y」不匹配DateTimeField字段。但我沒有找到解決辦法。
任何幫助將受到歡迎。謝謝。
完美。謝謝! – JojoL