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

254
Views
Cómo arreglar "getMonth" que muestra también el mes del próximo año

mi problema es que los meses se muestran hasta "abril", lo que significa que comienzan desde enero hasta abril del próximo año. Solo necesito mostrar meses hasta diciembre.

Este es mi código JavaScript

 var vals = [date.getFullYear() + (scale === YEAR ? qty : 0), date.getMonth() + (scale === MONTH ? qty : 0), date.getDate() + (scale === DAY ? qty : 0), date.getHours() + (scale === HOUR ? qty : 0), date.getMinutes() + (scale === MINUTE ? qty : 0), date.getSeconds() + (scale === SECOND ? qty : 0), date.getMilliseconds() + (scale === MILLISECOND ? qty : 0) ]; return new Date(...vals); }, start_of(date, scale) { const scores = { [YEAR]: 6, [MONTH]: 5, [DAY]: 4, [HOUR]: 3, [MINUTE]: 2, [SECOND]: 1, [MILLISECOND]: 0 }; function should_reset(_scale) { const max_score = scores[scale]; return scores[_scale] <= max_score; } const vals = [ date.getFullYear(), should_reset(YEAR) ? 0 : date.getMonth(), should_reset(MONTH) ? 1 : date.getDate(), should_reset(DAY) ? 0 : date.getHours(), should_reset(HOUR) ? 0 : date.getMinutes(), should_reset(MINUTE) ? 0 : date.getSeconds(), should_reset(SECOND) ? 0 : date.getMilliseconds() ]; return new Date(...vals); },

 <script> document.addEventListener('DOMContentLoaded', function() { var gantt_data = <?php echo json_encode($gantt_data); ?>; if (gantt_data.length > 0) { var gantt = new Gantt("#gantt", gantt_data, { view_modes: ['Day', 'Week', 'Month', 'Year'], view_mode: 'Month', date_format: 'YYYY-MM-DD', column_width: 30, }); $("#gantt g.handle-group").hide(); $('body').on('mouseleave', '.grid-row', function() { gantt.hide_popup(); }) $('select[name$="gantt_view"').change(function(el) { let view = $(el.target).val(); gantt.change_view_mode(view); }); } }) </script>

No estoy seguro de si algo más podría estar causando este problema. Estoy usando el diagrama de Gantt y solo quiero mostrar 12 meses.

Estoy usando este gantt. https://github.com/frappe/gantt

about 4 years ago · Juan Pablo Isaza
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!