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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Why is the date time less than 8 hours?

Thread ID:





140655 Oct 31,2018 12:58 AM UTC Nov 1,2018 07:57 PM UTC Angular - EJ 2 3
Tags: DateTimePicker
Asked On October 31, 2018 12:58 AM UTC

First I am in China, I am learning syncfusion angular controls.

My datetimepicker binding code as follow:
<ejs-datetimepicker name="startTime" placeholder="{{'starttime'|translate}}" floatLabelType="Auto" [(ngModel)]="a"></ejs-datetimepicker>

After saved to sql server, the date time is less 8 hours, how should I do ?

Before save:

After save:

Christopher Issac Sunder K [Syncfusion]
Replied On October 31, 2018 05:24 PM UTC

Hi Lorryl, 

Thanks for contacting Syncfusion Support. 

We have checked with your query and suspect that this issue may be raised because of assigning a ISO date string value directly (may be UTC converted  value of the component before saving) to the DateTimePicker component obtained from the server instead of assigning a Date object value. If this is your case, then please ensure to convert the UTC string value obtained from the server to a Date object value and then assign the resultant value to the component to overcome this issue at your end.  

If this is not your case, then please get back to us with more information so that we can validate more on this and provide an exact solution for your requirement. 

  1. Format in which the value is assigned to the DateTimePicker component.
  2. Whether date time value is stored as a string or Date time value
  3. Format of date value being sent to the server.
  4. Whether the Z factor from the ISO string is removed before being passed as value to the DateTimePicker component
  5. Code blocks or any issue reproducing sample for explaining your case will be helpful to get more clear information about your issue.

Replied On November 1, 2018 04:15 AM UTC

Sorry, I don't know what should I do.

I bind the datetime as follow:
<ejs-datetimepicker name="startTime" placeholder="{{'starttime'|translate}}" floatLabelType="Auto" [(ngModel)]="row.DocDate">

Get row data using "this.row = JSON.parse(data)", and Save row data using "JSON.stringify(this.row)". I don't use "moment" to process the row date value.

Should I use "moment" to solve the problem ? Can you give me a demo ?

Deepa Loganathan [Syncfusion]
Replied On November 1, 2018 07:57 PM UTC

Hi Lorryl,  
Sorry for the inconvenience.  
We have looked into your query and we suspect that you were trying to set the value of DateTimePicker as String. Setting Date value as an ISO String causes the Date value to be set based on the timezone factor, causing the difference in time while viewing in a client machine that has different timezone.  
So, we suggest using the Date of type Date time object instead of string values to overcome this issue.  
Regarding MomentJS 
Yes, you can even make use of MomentJS to overcome timezone discrepancies. We prepared a sample to showcase the usage of EJDateTimepicker with MomentJS. please check the sample in the below link.  
Please let us know if you have any further queries.  
Deepa L. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon