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

How to keep UTC value instead of local value

I need to display my value as UTC, the date passed in is a proper UTC date but it is being displayed as local with the proper offset being applied.  How do i configure the control to show it as UTC?  Thanks in advance

6 Replies

MS Mike Stankovich March 27, 2019 02:15 PM UTC

Anyone able to assist with this?


DL Deepa Loganathan Syncfusion Team March 28, 2019 05:50 AM UTC

Hi Mike,  

Sorry for the delay in responding your query.  

We would like to let you know that in EJ2 DateTimepicker control, we have not done any conversion with respect to Timezone and the value received will be formatted with respect to the given culture before being displayed in the input element.  

So, we would like to know more about your requirement. 

1.       Are you using EJ1 or EJ2 Datetimepicker 
 
2.       Are you using MVC helpers or Javascript controls in your application? 
 
3.       Exact requirement for this in your application.  
 
4.       Do you wish to show the Date object directly without formatting the given date? 
 
The details you provide would help us provide you a prompt solution based on your requirements. 

Regards,  
Deepa L. 



MS Mike Stankovich April 9, 2019 11:28 AM UTC

1. I'm using EJ2
2. Pure javascript
3. The requirement is pretty much my issue.  How can I not apply the culture and keep it UTC?
4. I want the datetime properly formatted without the timezone conversion to local.  Do i have to add my timezone offset to the control prior to setting it?

If given this date input
2017-06-10T12:15:00.000Z 

I want the control to render the time as 12:15 and not 8:15AM for eastern standard time.
My users do not want to see local times, they operate entirely in UTC


CI Christopher Issac Sunder K Syncfusion Team April 10, 2019 09:30 AM UTC

Hi Mike, 

We have checked the reported query and we would like to inform you that, while passing the date value with “z” within new Date() method, it will be rendered as UTC value with current time zone. So, if you pass the value as “2017-06-10T12:15:00.000Z” to the DateTimePicker component, it will be displayed the value as “8:15 AM” based on the new Date () method default functionality. Our EJ2 DateTimePicker component will be rendered based on the new Date () functionalities. 

So, we suggest you to specify the value without “z” to get UTC date value. We have prepared the sample and checked in the specified time zone (“eastern standard time”). Please find the sample from the below link. 

If still issue persist, please revert with issue reproducing sample or code example or modify the provided sample with reported issue or video demonstration of the reported issue that will help us to check and provide the exact solution at our end. 

Thanks, 
Christo 



MS Mike Stankovich April 10, 2019 10:26 AM UTC

While that is a workaround that works, your team realizes that is the exact opposite of what I should be doing?  There should ultimately be an option to specify this within the control.

Thank you, I'll make this work


CI Christopher Issac Sunder K Syncfusion Team April 11, 2019 01:18 PM UTC

Hi Mike, 

Thanks for the suggestion. But we would like to inform that, our EJ2 date components will be rendered based on the current machine local time as per the standard behavior. If you want to process the date value with desired format, you need to convert and make use of it as per the application needs externally. So, we could not provide the requested support for our date components in the source level. 

Please let us know if you have any concerns. 

Thanks, 
Christo 


Loader.
Live Chat Icon For mobile
Up arrow icon