DanielYKPan / date-time-picker

Angular Date Time Picker (Responsive Design)
https://daniel-projects.firebaseapp.com/owlng/date-time-picker
MIT License
562 stars 357 forks source link

UTC format without momentjs #611

Open ChristianKohler opened 5 years ago

ChristianKohler commented 5 years ago

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?

seabass223 commented 5 years ago

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);
  }
wwjd1234 commented 4 years ago

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