We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Date Picker DateTime.Kind changing

Hello

I have the following datepicker

<SfDatePicker Enabled="SelectedTime.CanEdit" id="selected-transactiondate" CssClass="e-outline" Format="dddd MMMM d yyyy" StrictMode=true Min="AppStateService.MinEntryDate" Max="AppStateService.MaxEntryDate" TValue="DateTime" @bind-value="SelectedTime.TransactionDate" Placeholder="Date" FloatLabelType="@FloatLabelType.Auto"></SfDatePicker>

It is bound to TransactionDate ( DateTime datatype).

I think something has changed recently

When I initialize the date it looks like this:


..that is a Utc date with no time.

After using the date picker to change the date, then the resulting date changes from Utc to Local and the hours, minutes, seconds change accordingly (to non-zero).  

This has caused havoc in my api.  

I have worked around using the following to set the date back to utc.

TransactionDate = DateTime.SpecifyKind(SelectedTime.TransactionDate, DateTimeKind.Utc)

Has something changed recently with this control?

Thank you



  










1 Reply

SP Sureshkumar P Syncfusion Team December 15, 2022 06:11 AM UTC

Hi Ditchford,

When validating the reported issue based on the shared code example the reported issue was not replicated from our end. find the validated sample and screenshot below.

Find the code example here:

 

<SfDatePicker Enabled="CanEdit" id="selected-transactiondate" CssClass="e-outline" Format="dddd MMMM d yyyy" StrictMode=true Min="MinEntryDate" Max="MaxEntryDate" TValue="DateTime" @bind-value="TransactionDate" Placeholder="Date" FloatLabelType="@FloatLabelType.Auto"></SfDatePicker>

 

<button @onclick="GetDate">Click To Get Date</button>

@code {

    public bool CanEdit { get; set; } = true;

    public DateTime MinEntryDate { get; set; } = new DateTime(2021, 03, 03);

    public DateTime MaxEntryDate { get; set; } = new DateTime(2025, 03, 03);

    public DateTime TransactionDate { get; set; } = DateTime.Now;

 

    void GetDate()

    {

        DateTime Date = TransactionDate;

    }

}


Find the screen shot here:


Find the sample in the attachment:

Also, share your old and new version changes and if still, you have faced the same issue, then replicate the reported issue on the attached sample and revert us with a detailed issue replication procedure. these details will help us to provide an exact solution as earlier as possible.

Regards,

Sureshkumar P


Attachment: DatePickerServer_3cbd74bb.zip

Loader.
Live Chat Icon For mobile
Up arrow icon