Date, Time display and convert

 // Conver UTC to NZ time (UI)
   data: 'timestamp', render: function (data: any, type: any, row: any) {
        return '<span class="text-success" >' +
         formatDate(new Date(data), 'dd/MM/yyyy HH:mm:ss', 'en-NZ', 'Pacific/Auckland')
   }
// Date range (min, max)

  setMinMaxDate() {
    const currentDate = new Date();
    const formattedDate = currentDate.toISOString().split('T')[0];
    this.minDate = formattedDate;
    let next30days = this.addDays(currentDate, 90);
    this.maxDate = next30days.toISOString().split('T')[0];
  }


  addDays(date: Date, days: number): Date {
    let result = new Date(date);
    result.setDate(date.getDate() + days);
    return result;
  }



  <input class="form-control" type="date" min={{minDate}} max="{{maxDate}}" formControlName="entryDate">

Last updated

Was this helpful?