BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
[.html]
<div class="content-container-fluid">
<div class="row">
<div class="cols-sample-area" style="height:400px; margin:0 auto;">
Datepicker
<input ej-datepicker dateFormat="dd/MM/yyyy" locale="en-GB"[(ngModel)]="startDate" id="startDate" >
<input type="submit" ej-button (click)="onclick($event)" />
</div>
</div>
</div> |
[.ts]
onclick() {
var datevalue = $("#startDate").val(); //get the value of the datepicker element.
var dateobject = ej.parseDate(datevalue,"dd/MM/yyyy","en-GB");// converting the value to Dateobject of specific format and culture.
alert("ISO value:"+dateobject .toISOString());// Value converted to ISO format will be available in alert textbox.
}
|
Hi Prem,
I am using Angular2 and TypesScript.
I have come up with this which seems to work well...
< input #startDate ej-datepicker dateFormat="dd/MM/yyyy" locale="en-GB" >
@ViewChild('startDate') startDate: any;
let startDate = new Date(this.startDate.widget._preValue);
Is this OK?
Thank you. Is there a more suitable variable I could use that would provide the selected date in ISO format - from TypeScript?
ngAfterViewInit() {
this.modeldate = this.startDate.widget.model.value;
}
|
[html]
<input #datepic ej-datepicker dateFormat="dd/MM/yyyy" locale="en-GB" [(value)]="value" (ejchange)="onChange($event)" id="datepicker" > |
[ts]
export class DatepickerComponent {
value: any;
modeldate:any;
@ViewChild("datepic") startDate: any;
constructor() {
this.value =new Date();
}
onChange(args) {
var dateobject = ej.parseDate(args.value, "dd/MM/yyyy", "en-GB");// converting the value to Dateobject of specific format and culture
this.modeldate = new Date(dateobject .toISOString());// Value converted to ISO format.
alert("ISO value:"+this.modeldate);
}
ngAfterViewInit() {
this.modeldate = this.startDate.widget.model.value;
}
} |
Many thanks Prem, this resolves the issue. Again great tech support!
Hoping this thread is of help to other developers.
Regards
Mark