Bootstrap 3 Datetimepicker 3.0.0 - make a week start on Monday

后端 未结 9 1095
广开言路
广开言路 2020-12-06 10:28

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 w

相关标签:
9条回答
  • 2020-12-06 10:50

    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.

    0 讨论(0)
  • 2020-12-06 10:52

    Instead of using moment.js I used moment-with-langs.js (I guess it came with default package ASP.NET MVC 5).

    By calling:

    <script type="text/javascript">
        $('#DateTime').datetimepicker({
            language: "hr"
        });
    </script>
    

    thing works, finally the calender starts from monday.

    UPDATE: Even better, add key to web.config

    <appSettings>    
        <add key="Culture" value="hr" />
    </appSettings>
    

    and then

    $(document).ready(function () {
        $(document).on('focus', '#Date', function () {
            $(this).datetimepicker({
                locale: '@System.Configuration.ConfigurationManager.AppSettings["Culture"]',
                format: 'DD:MM:YYYY',
            });
        });
    });
    
    0 讨论(0)
  • 2020-12-06 10:53

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

    • Bootstrap3 Datetimepicker (4.14.30)
    • Moment (2.10.3)

    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.
    };
    
    0 讨论(0)
  • 2020-12-06 11:02
    'locale' => [
        'firstDay' => 1
    ]
    
    0 讨论(0)
  • 2020-12-06 11:03

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

    0 讨论(0)
  • 2020-12-06 11:05

    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();
    
    0 讨论(0)
提交回复
热议问题