Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Date time Issue-During edit operations, getting date field as invalid input #6734


User avatar
0
kalidarscope created

15 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, is this generated by RAD tool?

    if not, please share the related code to display the view

  • User Avatar
    0
    kalidarscope created

    No.

       <input id="createdate" type="text"  name="creatioN_TIME" class="form-control" ui-date-format="mm/dd/yyyy" bsDatepicker [(ngModel)]="organization.creatioN_TIME" autocomplete="off">
          <input id="Expirydate" type="text" name="expirY_DATE" class="form-control" bsDatepicker [(ngModel)]="organization.expirY_DATE" ui-date-format="mm/dd/yyyy" autocomplete="off">
    

    In ts file to retrive data,

     this.CreateDate = new Date(moment(result.creatioN_TIME, 'YYYY-MM-DDTHH:mm:ss').format());
     this.ExpiryDate = new Date(moment(result.expirY_DATE, 'YYYY-MM-DDTHH:mm:ss').format());
    
  • User Avatar
    0
    maliming created
    Support Team

    @kalidarscope Please share the full code and values such as result.creatioN_TIME and result.expirY_DATE.

  • User Avatar
    0
    kalidarscope created

    creatioN_TIME: Moment {_isAMomentObject: true, _i: "2019-04-01T09:42:49", _f: "YYYY-MM-DDTHH:mm:ss", _isUTC: false, {_isAMomentObject: true, _i: "2019-04-30T09:42:49", _f: "YYYY-MM-DDTHH:mm:ss", _isUTC: false, _pf: {…}, …}

  • User Avatar
    0
    kalidarscope created

    Tue Mar 26 2019 05:30:00 GMT+0530 (India Standard Time)

  • User Avatar
    0
    kalidarscope created

    creationTime Result: Tue Mar 26 2019 05:30:00 GMT+0530 (India Standard Time)

  • User Avatar
    0
    alirizaadiyahsi created

    You are using this.CreateDate in .ts file but in html you are binding organization.creatioN_TIME. I couldn't understand your code.

    BTW, result.creatioN_TIME.format('YYYY-MM-DDTHH:mm:ss') is enough. moment methods already return a date object. Check moment docs for detailed info.

  • User Avatar
    0
    kalidarscope created

    In ts file,

    @ViewChild('createDate') createDate: ElementRef; @ViewChild('Expirydate') Expirydate: ElementRef;

    In Html file,
      &lt;input id=&quot;createDate&quot; type=&quot;datetime&quot; #createDate  [ngClass]=&quot;{&#39;edited&#39;:organization.creatioN_TIME}&quot;
                                name=&quot;createDate&quot; class=&quot;form-control&quot;  bsDatepicker [(ngModel)]=&quot;organization.creatioN_TIME&quot; autocomplete=&quot;off&quot;&gt;
                              
    
  • User Avatar
    0
    kalidarscope created

    Getting error, Type string is not assignable to type date

  • User Avatar
    0
    kalidarscope created

    ngAfterViewInit(): void { debugger if (this.organization.creatioN_TIME) { debugger (this.createDate.nativeElement as any).value = this.organization.creatioN_TIME.format('L'); }

  • User Avatar
    0
    maliming created
    Support Team

    Can you share the html and ts complete code of your component?

  • User Avatar
    0
    kalidarscope created

    Html: <input id="CreateDateUtc" type="datetime" #CreateDateUtc name="CreateDateUtc" class="form-control"
    bsDatepicker [(ngModel)]="organization.creatioN_TIME">

    Ts: if (this.organization.creatioN_TIME) { (this.createDateUtc.nativeElement as any).value = this.organization.creatioN_TIME.format('L'); }

    I hav used it in ngOnInit

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @kalidarscope

    Have you tried removing ui-date-format attribute ? AspNet Zero automatically shows the selected with the date format of selected language (culture).

  • User Avatar
    0
    kalidarscope created

    Hi @ismcagdas Where can we remove ui-date-format attribute?

    You already implememted date functionality in tenant. While you editing the tenant, you are showing proper format in SubscriptionEndDateUtc field. We just used the same code. But it shows wrong date or invalid date. Did you remove the ui-date-format attribute for this field that you have in tenant form.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I checked the source code again and couldn't find any usage of "ui-date-format" which you mention in your second post:

    So, did you try to remove it ? If so, what happened ?