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

140
Views
Me gustaría verificar si la hora actual es antes de las 11:00 con moment.js. ¿Cómo puedo conseguir esto?

Estoy trabajando con la biblioteca moment.js, si quiero verificar si la hora actual es inferior a las 11:00 o no, ¿cómo logro esto?

 let todaysDate = moment() // "yyyy-mm-dd" var time = "22:59"; // set condition to just before 11:00 var elevenOclockTimeCheck = moment(todaysDate).startOf(time); // check to see if time is equal or greater to 11:00 PM console.log(elevenOclockTimeCheck); // If it is before 11:00 then execte if block if (todaysDate < elevenOclockTimeCheck) { }
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Puedes usar el siguiente código:

 moment().isBefore(moment({ hour:11, minute: 0}));
about 4 years ago · Juan Pablo Isaza Report

0

Tenga en cuenta que no necesita moment.js para esto : la manipulación directa de fecha / hora de js lo hará.

 const todaysDate = new Date(); const hours = todaysDate.getHours(); const isBefore11 = hours <= 11; const result = `The time ${isBefore11 ? 'is' : 'is not'} before 11`; console.log(result); // my current time is 11:02pm (23:02)- so this consoles 'The time is not before 11'

about 4 years ago · Juan Pablo Isaza Report

0

Simplemente llame al captador de .hour y compare

 moment().hour() < 11;
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!