Kendo UI Date Picker Format - Forum - OpenEdge General - Progress Community

Kendo UI Date Picker Format

 Forum

Kendo UI Date Picker Format

This question is not answered

Hi,

I was wondering if anyone has had problems with getting a formatted date from the kendo ui date picker?

<label class="k-form-field">
<span>Required From</span>
<kendo-datepicker
[(ngModel)]="fromDate" [ngModelOptions]="{standalone: true}"
[format]="'dd-MM-yyyy'"
(valueChange)="onChangeFromDate($event)"
[value]="value">
</kendo-datepicker>
</label>
public onChangeFromDate(value: Date): void {
console.log("onChangeFromDate",[`${event}${this.formatValue(value)}`].concat(this.events));
console.log("onChangeFromDate",this.fromDate);
}

The first console log gives an object;

onChangeFromDate

  1. ["[object MouseEvent] - 6/30/2018"]
    1. 0:"[object MouseEvent] - 6/30/2018"
    2. length:1
    3. __proto__:Array(0)

The second console log gives;

"onChangeFromDate Sat Jun 30 2018 00:00:00 GMT+0100 (British Summer Time)"

Ideally, I'd like to extract dd-mm-yyyy without writing a convaluted format function.

Any help would be greatly appreciated.

Thanks,

Mark

All Replies
  • console.log(this.fromDate.toLocaleDateString("en-GB"))

    see... developer.mozilla.org/.../toLocaleDateString

    console.log(this.fromDate.toLocaleDateString("en-GB").replace(/\//g,"-"))

    will replace the slashes with hyphens

  • Thanks for the help. I managed to resolve it (sort of) with this;

    this.fromDate = this.intl.formatDate(value, 'd-MM-y');

    which gives me a string in the form "dd-mm-yyyy"

    This works but then gives me another error after the assign;

    "ERROR Error: Uncaught (in promise): Error: The 'value' should be a valid JavaScript Date instance."