-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question for Binders and Converters Date&Time #1320
Comments
Has anyone encountered this problem and is there a way to fix it? |
Can you try with google chrome and check the datetime value for your request in network tab of developers console ? If we can see the value send to server in ajax request, we can better understand the problem. |
Hi @ismcagdas ; Abp cannot (Automatically) convert client datetime to UTC time. But I can use monent timezone plugins to convert datatime to I want (my local or any timezone). I thinks the start date&time(2016-08-29 12:42) or end date&time should be convernt UTC time to save to database. But it does not do it. It is still (2016-08-29 12:42) in database. Abp Document has a description :
Maybe I missed something, If I am wrong, please give me some tips. |
Hi, Thanks for detailed screenshots. When you send a datetime value without timezone information like this one "2016-08-29 16:49:00", it's Kind property is set to Unspecified and when it comes to UtcClockProvider's normalize method we only set it's Kind property to UTC. We dont convert it to UTC datetime because we cannot know it's original value is either local or utc. I suggest you to send a datetime value to server in UTC or local format like '2016-08-29T10:49:00Z' or '2016-08-29T16:49+600'. I think if you get the datetime value of your datepicker, it should give you something like this. |
Hi @ismcagdas ; Thanks for your replay. I will try it as your suggestions. Could Abp do it like this:
|
Which datepicker do you use by the way ? And I suggest you to use momentjs timezone library (http://momentjs.com/timezone/) if you are going to use timezone setting for each user. You just need to set it's default timezone value to user's timezone setting. |
I used two kinds of datepicker :
BTW,SO all datetimes convert to local datetime (User's timezone) are in client-side. Is it right? |
I have take a look at the periodpicker and it has a "value" method and it returns the datetime value(
If you use UtcClockProvider, datetime values are sent to client in UTC. Then you need to convert this datetime to user's timezone in the client. ABP does not do anything automatically. You can use abp.timing.convertToUserTimezone javascript function is defined here https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Web.Resources/Abp/Framework/scripts/libs/abp.moment.js |
Hi @ismcagdas, To use TimezoneHelper.ConvertFromUtc method I will implement a custom AbpSession to get TimezoneId for each user. if he has his own timezone. Thk your very much again. |
We will try to improve timezone documentation. Thanks for your suggestion. |
Hi @hikalkan,
According to Abp document :
Binders and Converters
For #1, Abp can normalizes DateTime received from Clients. But it is no use for me.
In my UI as shown below
it can not be converted to UTC date&time to save to my database. Maybe I missed something. Please give me some suggestions, thanks.
I added this code in my project :
it is in Application_Start
The text was updated successfully, but these errors were encountered: