8

Ci sono alcuni motivi per cui utilizzo Bootstrap 3 Datetimepicker 3.0.0 https://www.nuget.org/packages/Bootstrap.v3.Datetimepicker/ nel mio progetto MVC 5.Bootstrap 3 Datetepeper 3.0.0 - settimana inizia lunedì

Qualche idea su come compensare l'inizio della settimana in modo che inizi da lunedì. Anche il tag della lingua non funziona.

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

Questo non funziona perché non è la stessa di bootstrap-datapicker.js

risposta

3

Invece di usare moment.js ho usato moment-with-langs.js (credo sia venuto con il pacchetto predefinito ASP.NET MVC 5).

Chiamando:

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

cosa funziona, infine, il calendario parte da lunedi.

UPDATE: chiave Ancora meglio, metti in web.config

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

e poi

$(document).ready(function() { 
    $(document).on('focus', '#Date', function() { 
     $(this).datetimepicker({ 
      locale: '@System.Configuration.ConfigurationManager.AppSettings["Culture"]', 
      format: 'DD:MM:YYYY', 
     }); 
    }); 
}); 
4

Secondo le opzioni per DateTimePicker ciò non è possibile. Supporta solo le seguenti proprietà:

$.fn.datetimepicker.defaults = { 
    pickDate: true,     //en/disables the date picker 
    pickTime: true,     //en/disables the time picker 
    useMinutes: true,    //en/disables the minutes picker 
    useSeconds: true,    //en/disables the seconds picker 
    useCurrent: true,    //when true, picker will set the value to the current date/time  
    minuteStepping:1,    //set the minute stepping 
    minDate:`1/1/1900`,    //set a minimum date 
    maxDate: ,  //set a maximum date (defaults to today +100 years) 
    showToday: true,     //shows the today indicator 
    language:'en',     //sets language locale 
    defaultDate:"",     //sets a default date, accepts js dates, strings and moment objects 
    disabledDates:[],    //an array of dates that cannot be selected 
    enabledDates:[],    //an array of dates that can be selected 
    icons = { 
     time: 'glyphicon glyphicon-time', 
     date: 'glyphicon glyphicon-calendar', 
     up: 'glyphicon glyphicon-chevron-up', 
     down: 'glyphicon glyphicon-chevron-down' 
    } 
    useStrict: false,    //use "strict" when validating dates 
    sideBySide: false,    //show the date and time picker side by side 
    daysOfWeekDisabled:[]   //for example use daysOfWeekDisabled: [0,6] to disable weekends 
}; 

Source: http://eonasdan.github.io/bootstrap-datetimepicker/#options

È possibile disattivare il fine settimana, se non si vuole vedere domenica.

+0

Ma la colonna è ancora a sinistra e la gente si aspetta lunedì – HerGiz

+0

In bootstrap-datapicker.js ho spostato i nomi, ma solo i nomi vengono mooved, non le date stesse, quindi l'intero calendario non è corretto. Eaven treid cambiando in moment.js, ma la stessa cosa. – HerGiz

+0

Qualche suggerimento sostitutivo? – HerGiz

-1

aperti jquery.datetimepicker.js e trova variabile "dayOfWeekStart" e impostarlo su

+2

L'OP si riferiva a [Eonasdan Bootstrap-Datepicker] (http://eonasdan.github.io/bootstrap-datetimepicker/). Questo non ha nulla a che fare con il datepicker di jQuery. –

+0

Niente a che vedere con la domanda dell'OP. – FrenkyB

4

Ho appena fatto! In moment.js cambiare questa linea:

_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' deve essere 1 e la settimana inizia alle Lunedi.

0
'locale' => [ 
    'firstDay' => 1 
] 
23

Se si utilizza moment.js da v2.8.1 in poi, aggiungere il codice riportato di seguito prima di chiamare datetimepicker().

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

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

Se si utilizza vecchia versione di moment.js, effettuare le seguenti operazioni

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

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

mi sono imbattuto la stessa domanda, e sto usando:

E, in seguito alla risposta di user3928861 ho trovato la risposta alla riga 961 del momento.js come segue:

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

È può anche ignorare il valore di dow tramite la locale quando si chiama datetimepicker()

$('#myid').datetimepicker({ 
    format:'YYYY-MM-DD', 
    locale: moment.locale('en', { 
     week: { dow: 1 } 
    }), 
}); 
Problemi correlati