Breeze DataType.parseDateFromServer in the TypeScript project -
i using temphire angular 2 reference architecture in current project. facing same issue in following stackoverflow thread i.e unable save date value in sql server input user due utc issue.
breezejs: date not set right time
in angular2/typescript project, can changes described in above url. typescript syntax appreciated.
note: have included momentjs in project.
please refer. https://github.com/breeze/temphire.angular/issues/12
if has similar requirements, have done below.
inside prepare() { ......... ......... datatype.parsedatefromserver = this.parsedateasmoment; ......... ......... }
parsedateasmoment(source: any): date{
var date = moment.utc(source, 'yyyy-mm-dd hh-mm-ss'); return date.todate();
}
in angular component, ondatechanged event of mydatepicker.
ondatefromchanged(event: imydatemodel) {
if (event.formatted !== '') { var newdate = moment.utc(new date(event.jsdate).tolocaledatestring()).format('yyyy-mm-dd hh-mm-ss') var newdate2 = moment.utc(newdate, 'yyyy-mm-dd hh-mm-ss'); this.model.datefrom = newdate2.todate(); }
}
only date input stores correctly in sql server datetime column.
Comments
Post a Comment