Hilios Jquery倒计时本地化

时间:2014-06-19 19:22:39

标签: javascript jquery

您好我正在使用Hilios Jquery Countdown https://github.com/hilios/jQuery.countdown

多个实例的示例:

<div data-countdown="2014/06/20 20:00"></div>
<div data-countdown="2014/06/21 20:00"></div>
<div data-countdown="2014/06/22 20:00"></div>

JS:

$('[data-countdown]').each(function () {
    var $this = $(this), finalDate = $(this).data('countdown');
    $this.countdown(finalDate, function (event) {
        var format = '%H:%M:%S';
        if (event.offset.days > 0) {
            format = '%-d day%!d ' + format;
        }
        if (event.offset.weeks > 0) {
            format = '%-w week%!w ' + format;
        }
        $(this).html(event.strftime(format));
    });
});

问题在于,如果我在浏览器中选择一些欧洲语言(德语,斯洛文尼亚语),浏览器会自动将字符串日期从2014/06/20格式化为2014.06.20,这会使脚本无效。为什么会这样?我是否将日期值传递给数据属性错误?

当我在这里看到他们的例子:http://hilios.github.io/jQuery.countdown/examples/multiple-instances.html它适用于所有语言......但他们没有HTML实现的例子,只有我这样做的方式,但不知怎的,它们起作用。< / p>

有人有这个问题吗?

1 个答案:

答案 0 :(得分:0)

我必须使用CultureInfo.InvariantCulture。