Base solution for your next web application

Activities of "cclok89"

I think I know why already.

ngx-bootstrap datepicker cannot support moment object binding to ngModel, that why using ._d to make it Date object.

<input class="form-control m-input" type="datetime" bsDatepicker [(ngModel)]="date._d" id="Date" name="Date">

Since I enabled UTC mode, ._d object carry the UTC date and convert again to UTC datetime to the backend, that I always cannot get the correct UTC datetime. End up when displaying in the label, it always shows one day before the exact date. So, remove ._d, create a Date object and use toDate() to convert moment object to Date obejct will solve the issue for Result 2.

I found that there is ._d in the input which messed up the utc datetime.

I am using ASP.Net Core Angular version 7.0.0.

Scenario: When I select a date with datepicker (29/10/2019) in the UI, I get one day before the date (28/10/2019) in the backend, and stored the date (28/10/2019) in database.

Solutions: Use Clock.Now; for date Set Clock.Provider = ClockProviders.Utc; in Startup.cs Set Timezone (UTC+8) in Host and Tenant Setting page

Results:

  1. The saved date show correctly (29/10/2019) in the UI label, even the date in the database is different (28/10/2019).
  2. When I select a new date with datepicker (30/10/2019) in the UI, I get one day before the date (29/10/2019) in the backend, and stored the date (29/10/2019) in database. However in the UI datepicker it show correct date (30/10/2019) even the label show differently (29/10/2019).

Questions:

  1. Is that my solution correct? Anything else I need to do?
  2. Is that it work as described in the result? Date in the UI (UTC+8) and database (UTC+0) are different?
  3. For date only, should I use Clock.Now.Date so that the issue in result 2 will be solved?
  4. How if tenant based in Singapore set Timezone to Singapore Standard Time and user from Thailand using S.E. Asia Standard Time? Is that configured by changing Language flag can work?
Showing 1 to 3 of 3 entries