Robert Michalski
Robert Michalski

Reputation: 1

ng-bootstrap-datetime-angular change to 24hour format

How to convert the calendar into 24h format?

<form>
    <div [formGroup]="formGroup">
      <ng-bootstrap-datetime-angular
        placeholder="Select DateTime"
        inputDatetimeFormat="dd/MM/yyyy HH:mm "
        formControlName="activeEndDate"
        name="activeEndDate"
      ></ng-bootstrap-datetime-angular>
    </div>
  </form>
formGroup: FormGroup;

  ngOnInit() {
    this.formGroup = new FormGroup({
      activeEndDate: new FormControl(null, {
        validators: [Validators.required]
      })
    });
  }

demo: https://stackblitz.com/edit/ng-bootstrap-datetime-angular-zcwbcr?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts

Upvotes: 0

Views: 134

Answers (1)

codewithharshad
codewithharshad

Reputation: 361

Use this One


let ngbDate = this.form.controls['due_date'].value;
    let myDate = new Date(ngbDate.year, ngbDate.month-1, ngbDate.day);
    let formValues = this.form.value;
    formValues['due_date'] = myDate;
    <...>
    http.post(url, formValues);

Upvotes: 0

Related Questions