Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
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);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

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')"  !!};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!