cipchk / ngx-countdown

Simple, easy and performance countdown for angular
https://cipchk.github.io/ngx-countdown/
MIT License
192 stars 57 forks source link

Format error when displaying ngx countdown #55

Closed anuragd7 closed 4 years ago

anuragd7 commented 4 years ago

https://stackblitz.com/edit/ngx-countdown-setup 重现问题 [ x] Bug report [x ] Documentation issue or request

Current behavior

I want to display only hours and minutes in my ngx-countdown. I dont want to display seconds. I have set this up as follows in the code below:

html `<countdown

cd

                [config]="{ leftTime: leftTime, format: 'h:m', notify: [600, 120] }"
                (event)="handleEvent($event)"
              ></countdown>`

The left time is calculated as follows: ts `startCountDown(reviewEnd: string) {

const endTime = new Date(reviewEnd);
 const now = new Date();
if (now < endTime) {
  this.countdownExists = true;
  const endMilliSeconds = endTime.getTime();
  const nowMilliSeconds = now.getTime();
  this.leftTime = (endMilliSeconds - nowMilliSeconds) / 1000;
}

}`

The time is now displaying correctly when there is atleast one hour left as below image

However when the time is below 1 hour it shows it incorrectly as 12:22. See pic below image

Expected behavior

I would expect the time to be shown as 00:22.

Environment

Angular version: 8.2.14 ngx-countdown version: 8.0.2

Browser:

DaveOdden commented 4 years ago

Use HH or H in your format. The link to accepted date/time formats in the documentation is a good reference.

anuragd7 commented 4 years ago

Thanks that solved it!