Search code examples
jquerytwitter-bootstrapasp.net-mvc-5datetimepickereonasdan-datetimepicker

Bootstrap 3 Datetimepicker 3.0.0 - make a week start on Monday


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


Solution

  • 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',
            });
        });
    });