• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

152
Vistas
js Daterange Picker time picker showing current time in time range

I want to show time from 00:00 to 23:59 in custom range option for time picker. By default custom range is selected for me. It works with predefined ranges but not with custom range. I couldn't find any option in docs to set time picker range for custom range time picker. Here is my initialization code.

            var start = {!! isset($_GET['from'])?"moment('".$_GET['from']."')":"moment().startOf('today')"  !!};
            var end = {!! isset($_GET['to'])?"moment('".$_GET['to']."')":"moment().endOf('today')"  !!};

            function cb(s, e) {
                start = s;
                end = e;
                $('#reportrange span').html(start.format('MMM D') + ' - ' + end.format('MMM D'));
            }

               $('#reportrange').daterangepicker({
                timePicker: true,
                timePicker24Hour: true,
                startDate: start,
                endDate: end,
                ranges: {
                    'Today': [moment().startOf('day'), moment().endOf('day')],
                    'Yesterday': [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')],
                    'Last 7 Days': [moment().subtract(6, 'days').startOf('day'), moment().endOf('day')],
                    'Last 30 Days': [moment().subtract(29, 'days').startOf('day'), moment().endOf('day')],
                    'This Month': [moment().startOf('month').startOf('day'), moment().endOf('month').endOf('day')],
                    'Last Month': [moment().subtract(1, 'month').startOf('month').startOf('day'), moment().subtract(1, 'month').endOf('month').endOf('day')]
                }
            }, cb);
almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You just need to change moment startOf from today to day. Currently its not getting date so it selects custom range by default.

You can look in to moment docs

https://momentjs.com/docs/#/manipulating/start-of/

var start = {!! isset($_GET['from'])?"moment('".$_GET['from']."')":"moment().startOf('day')"  !!};
var end = {!! isset($_GET['to'])?"moment('".$_GET['to']."')":"moment().endOf('day')"  !!};
almost 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda