date-time-picker icon indicating copy to clipboard operation
date-time-picker copied to clipboard

UTC format without momentjs

Open ChristianKohler opened this issue 6 years ago • 2 comments

Example

https://stackblitz.com/edit/angular-zopu43

Screenshot 2019-07-03 at 10 48 40

Question

Is it possible to set the formatted date to utc, not local time?

ChristianKohler avatar Jul 03 '19 08:07 ChristianKohler

I'm not sure if there is a way to do this automatically or not. Manually you can subscribe to the <input (dateTimeChange)="dateTimeChangeInternally($event)" and then add the timezone offset to the selected date

  public dateTimeChangeInternally(e: {
    source: OwlDateTimeInputDirective<any>;
    value: Date[];
    input: HTMLElement;
  }): void {
     const startDate = e.value[0];
     const utcDate = startDate.addMilliseconds(startDate.getTimezoneOffset() * 60 * 1000);
  }

seabass223 avatar Sep 26 '19 16:09 seabass223

addMilliseconds does not exist for type date. Also why are you adding the offset?

wwjd1234 avatar Aug 04 '20 00:08 wwjd1234