Bootstrap 3 Datetimepicker 3.0.0 - make a week sta

2020-02-01 07:06发布

There are few reasons I use Bootstrap 3 Datetimepicker 3.0.0 in my MVC 5 project.

Any idea how to offset week start so it starts from Monday? Language tag also not working.

 $(function () {
    $('#PickupTime').datetimepicker({
     weekStart: 1
    });
 });

This is not working because it is not the same bootstrap-datapicker.js

9条回答
孤傲高冷的网名
2楼-- · 2020-02-01 07:19

You can also override the dow value via the locale when calling datetimepicker()

$('#myid').datetimepicker({
    format:'YYYY-MM-DD',
    locale:  moment.locale('en', {
        week: { dow: 1 }
    }),
});
查看更多
仙女界的扛把子
3楼-- · 2020-02-01 07:20

I have just done! In moment.js change this line:

_week : {
    dow : 1, // Sunday is the first day of the week.
    doy : 6  // The week that contains Jan 1st is the first week of the year. 
},

'dow' MUST BE 1 and the week starts at Monday.

查看更多
何必那么认真
4楼-- · 2020-02-01 07:26

open jquery.datetimepicker.js and find variable "dayOfWeekStart" and set it to 1

查看更多
不美不萌又怎样
5楼-- · 2020-02-01 07:31

I stumbled upon the same question, and i'm using:

And, following the answer of user3928861 I found the answer on line 961 of moment.js as follows:

var defaultLocaleWeek = {
    dow : 1, // Sunday is the first day of the week.
    doy : 6  // The week that contains Jan 1st is the first week of the year.
};
查看更多
6楼-- · 2020-02-01 07:33
'locale' => [
    'firstDay' => 1
]
查看更多
Root(大扎)
7楼-- · 2020-02-01 07:34

If you are using moment.js from v2.8.1 onwards, add the below code before calling datetimepicker().

moment.updateLocale('en', {
  week: { dow: 1 } // Monday is the first day of the week
});

$('#DateTime').datetimepicker();

If you are using old version of moment.js, do the following

moment.lang('en', {
  week: { dow: 1 }
});

$('#DateTime').datetimepicker();
查看更多
登录 后发表回答