SKL
SKL

Reputation: 1443

How to convert date timezone to utc using momentjs in Angular 6

I'm having issue to convert date with timezone to utc format.

How to convert 2019-06-13T00:00:00+08:00 to this format 2019-06-12T16:00:00.000Z

app.ts

orders() {
  this.orderService
    .orders(
      this.selectedType.value,
      moment(this.startDate).utc().format('YYYY-MM-DD HH:mm Z'),
      moment(this.endDate).utc().format('YYYY-MM-DD HH:mm Z'),
    )
    .pipe(takeUntil(this.allSub))
    .subscribe(
      res => {
        this.loading.stop();
      },
      err => {
        serviceHttpErrorHandler(err);
      },
    );
}

Upvotes: 0

Views: 5198

Answers (1)

lorenago
lorenago

Reputation: 435

Try this: moment(this.startDate).utc().format()

Hope it helps!

Upvotes: 1

Related Questions