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

Unable to set current time in DateTimeEdit

When today button is pressed in drop down calender, it sets the today's date but resets the time to 00:00:00 if using HH format and even if I set using DateTimeEdit.DateTime = DateTime.Now; it does same thing.
Is there any way to fix it ?

5 Replies

KP Kanniyappan Panneer Selvam Syncfusion Team September 19, 2019 11:01 AM UTC

Hi John, 
 
Thanks for contacting syncfusion support. 
 
We have checked your query “Time resets to 00:00:00 when press today button in DateTimeEdit” at our end. We can achieve your requirement by the setting the DateTime.Now value to DateTimeEdit when click today button and it can be retrieved by DateTimeChanged event of DateTimeEdit. Please find the code snippet, screenshot and sample for the same.  
 
Code Snippet: 
 
dateTimeEdit.DateTimeChanged += DateTimeEdit_DateTimeChanged; 
 
/// <summary> 
        /// Event triggers when current date time is changed 
        /// </summary> 
        private void DateTimeEdit_DateTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
       
            dateTimeEdit.DateTime = DateTime.Now; 
        } 
 
 
Screenshot: 
 
 
 
 
Please try the above solution and let us know  if it is helpful. 
 
Regards, 
Kanniyappan P 



JO John replied to Kanniyappan Panneer Selvam September 19, 2019 12:35 PM UTC

Hi John, 
 
Thanks for contacting syncfusion support. 
 
We have checked your query “Time resets to 00:00:00 when press today button in DateTimeEdit” at our end. We can achieve your requirement by the setting the DateTime.Now value to DateTimeEdit when click today button and it can be retrieved by DateTimeChanged event of DateTimeEdit. Please find the code snippet, screenshot and sample for the same.  
 
Code Snippet: 
 
dateTimeEdit.DateTimeChanged += DateTimeEdit_DateTimeChanged; 
 
/// <summary> 
        /// Event triggers when current date time is changed 
        /// </summary> 
        private void DateTimeEdit_DateTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
       
            dateTimeEdit.DateTime = DateTime.Now; 
        } 
 
 
Screenshot: 
 
 
 
 
Please try the above solution and let us know  if it is helpful. 
 
Regards, 
Kanniyappan P 


Its a bug, the suggested code snippet will not allow any other date to be set than today's.  You should add a bug fix in next version.


KP Kanniyappan Panneer Selvam Syncfusion Team September 20, 2019 01:41 PM UTC

Hi John, 
 
Thanks for your update. 
 
The reported behavior is not an issue, because when click the today button, we have updated Date only instead of updating DateTime.Now to DateTimeEdit. Because the time will varies based on each and every second. So only we could not update the current time value to DateTimeEdit when click the today button.  
 
Please let us know if you have any queries on this. 
 
Regards, 
Kanniyappan P 
 



JO John replied to Kanniyappan Panneer Selvam September 25, 2019 05:24 AM UTC

Hi John, 
 
Thanks for your update. 
 
The reported behavior is not an issue, because when click the today button, we have updated Date only instead of updating DateTime.Now to DateTimeEdit. Because the time will varies based on each and every second. So only we could not update the current time value to DateTimeEdit when click the today button.  
 
Please let us know if you have any queries on this. 
 
Regards, 
Kanniyappan P 
 


Then try set dateTimeEdit.DateTime = DateTime.Now;  in Windows_Loaded event.


KP Kanniyappan Panneer Selvam Syncfusion Team September 26, 2019 01:06 PM UTC

Hi John, 
 
We have checked your reported query “Provide support to update the DateTime value based on DateTimeFormat when click the today button in DateTimeEdit” and we have logged the feature request regarding your requirement and it can be tracked through below feedback portal link.  
 
 
If you have any more specification/suggestions to the feature request you can add it as a comment in the portal. 
 
This feature will be available in our upcoming Vol 3 SP1, 2019 release.  
 
Regards, 
Kanniyappan P 


Loader.
Live Chat Icon For mobile
Up arrow icon