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

113
Views
verifique si el tiempo está en el rango entre las 12:00 a. m. y las 6:59 a. m.

Uso angular e iónico 4. Tengo problemas para verificar el rango de tiempo entre las 12:00 a. m. y las 6:59 a. m.

Código de ejemplo como se muestra a continuación

HTML

 <ion-datetime[(ngModel)]="data.laterTime" (ionChange)="saveDate($event)" displayFormat="HH:mm" min="00:00" max="23:59" hourValues="00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23" minuteValues="0, 15, 30, 45"> </ion-datetime>

t

 saveDate($event) { if (moment($event.detail?.value).format('hh:mm a') <= '12:00 am' && moment($event.detail?.value).format('hh:mm a') < '07:00 am') { console.log("success!!!"); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solo necesita convertir cada cadena de tiempo en momento y compararlo. Como esto:

 wrapIntoMoment(value: string) { return moment(value, 'h:mma'); } saveDate($event) { if ( this.wrapIntoMoment($event.detail?.value) >= this.wrapIntoMoment('12:00 am') && this.wrapIntoMoment($event.detail?.value) < this.wrapIntoMoment('06:59 am') ) { console.log('success!!!'); } }

Hay un ejemplo para usted con algunos casos de prueba en el constructor: Ejemplo

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!