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

DateTime Field - Invalid date #5917


User avatar
0
kpmg created

Hi all!

I have used the RAD tool for my application. Everything worked fine beside the datepicker. I can select a date and it got stored to the object and the database. If I edit the object I get the message "Invalid date".

Where does this come from and how can i solve this issue?

Thanks a lot!


14 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @christianw

    Sorry for our late response.

    • Which version of AspNet Zero and RAD Tool do you use ?
    • Are you using Angular or JQuery version ?

    Thanks.

  • User Avatar
    0
    abdourahmani created

    Hi, I have the same problem with datepicker.

    Dates come from database and are displayed well in p-table. But all are marked "invalid date" in datepicker.

    But when I change the default language to "English", some are displayed but have wrong values. Years are correct. But all dates are 01/20/yyyy.

    v6.0.0.0 Angular/Asp .net core RAD 1.6.3, but the component must have been genereated with previous version, 2 weeks ago

    Thanks.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @abdourahmani

    Could you write the steps to reproduce this problem ? We can test and fix it according to your explanation.

  • User Avatar
    0
    abdourahmani created

    Hi @ismcagdas ,

    I didn't do any manipulation. just using code generated by the RAD tool and data come from database.

  • User Avatar
    0
    Mitch created

    Are you trying to use British English date format?

    If so, I have an ongoing battle with it when using ASP Net Zero as it seems give it USA date settings.

    As an example, if I select the ASP Net Zero Language from the dropdown as French then I get "dd/mm/yyyy" which is correct. But if I set the Language to British English (en-gb) I get the US Date format "mm/dd/yyyy" instead of "dd/mm/yyyy",despite specifying en-gb when setting adding the Language as an option to the list.

    Out of desperation I have totally removed the US English "en" option from the database. It then seems to behave itself. Might be worth a try.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @abdourahmani Thanks, I will try this with the RAD Tool.

    @mitch are you also using Angular version ?

  • User Avatar
    0
    Mitch created

    I'm using ASP.NET Core MVC & JQuery.

  • User Avatar
    0
    blueoceandev created

    I have the same issue ASPNetzero: 6.3.1 Angular: ^7.0.3 ngx-bootstrap: ^3.1.1

    I can confirm that the data being saved when I first save the form is sent correctly, and the date that comes back (it comes back and is convereted into a moment by something in the framework) is the correct value as well..

    But I just set the date to 11/2/2018, and it is displaying as 03/20/2018... I have also seen it display as 01/20/2018

    Josh

  • User Avatar
    0
    blueoceandev created

    The issue is here in configFromStringAndFormat() in ngx-bootstrap-chronos.js

    I am not sure that the issue is actually in ngx-bootstrap, but here is where it presents itself.

    ngx-bootstrap assumes the string coming out of calling .toString() on the date (which is a moment object) will be MM/DD/YYYY but its actually much different... The result is the parsing is completely off the rails and it returns a wacky date.

    I don't know if there is configuration happening in ASPNetZero somewhere telling Moment to default to the long format it is using here or if there is configuration somewhere to tell ngx-bootstrap to use MM/DD/YYYY format on this string..

  • User Avatar
    0
    blueoceandev created

    I did a bunch of digging... Definetly something up between Moment and ngx-bootstrap.. I have submitted a ticket.. But if this worked before, perhaps we should pin package.json to a known good ngx-bootstrap?

    here is the issue report on github https://github.com/valor-software/ngx-bootstrap/issues/4826

  • User Avatar
    0
    blueoceandev created

    And ngx-bootstrap just closed the issue as by design. :-(

  • User Avatar
    0
    blueoceandev created

    last comment (sorry grinding on this for a while)..

    I have a fix if you don't care about time

    place these two lines around line 152 in AppPreBootstrap.ts

    (moment as any).fn.toString = function() { return this.format("L"); };
    (window as any).moment.fn.toString = function() { return this.format("L"); };
    

    this will universally change how moment's .toString() function works..

    I don't have a better long term idea of how to handle this, but then again, I am just a user so.... ;-)

  • User Avatar
    1
    ismcagdas created
    Support Team

    @catapult

    Could you create an issue on https://github.com/aspnetzero/aspnet-zero-core/issues about this ?

    We might change ngx-bootstrap datepicker with PrimeNG calendar. We had many problems about ngx-bootstrap datepicker and we will consider replacing it.

    Thanks

  • User Avatar
    0
    yekalkan created

    See https://github.com/aspnetzero/aspnet-zero-core/issues/2043#issuecomment-450841752