-
Notifications
You must be signed in to change notification settings - Fork 203
Date in UTC format #88
Comments
I think the datepicker will use a localised time. I have resolved this for now by adjusting the value before posting it to the server. I'll be looking into it more closely later. Here's the adjustment in case it is of use: |
This is a good solution for sending information back to the server using UTC, but it doesn't help if you're storing defaults and want those to be used on load (and filled in the input boxes). Anyone else have a solution? |
@fizerkhan As you would have noticed, the datepicker gives the time in the ISOString format If you select To get back the correct time on server-side, you need to know what Timezone the data was sent from. But I'd advice against doing that. Keep your server-side data to be always in the UTC format, and on the client-side, just do a |
@kumarharsh Thanks, i understood your points. But I am really surprised that someone selecting date 15 August, i would expect two possibilities
Here, It is giving current time in UTC. This is really confusing behaviour. I never seen this behaviour in any date picker |
But this is the correct behaviour. The Date object itself can show you data in ANY timezone. I can't comment on the way it stores it internally, but that date which is given out of the plugin is easily transformable, as I underlined above. The reason the plugin shows time in UTC is the same reason we communicate in GMT (if we are talking to anyone in another country) It's easiest to understand (after a little adjustment) and it's unambiguous. Anyways, you are just ONE developer, and can write a few lines of code to do the transforms. The only thing to keep in mind is that the users should never see time in UTC, but in localized time only. This issue can be closed IMO. |
@kumarharsh Thanks for your points. It is not about whether we can do it by few lines of code. Why this date picker behave different from other date pickers? I expected to get more thoughts from others on this issue. |
Which other date pickers are you talking about? Perhaps you could share the links? |
Following are the date pickers that i used in other projects (Backbone.js and Ember.js)
|
I think you can ask the maintainer of the repo, he'd be the best person to get the answers from! That being said, you can specify your own format, failing which the plugin falls back to ISO format. |
On second thoughts, I see your point that there is a strong reason to expect the local time to be given by the picker as the default. |
There is one use case when local-UTC conversions must not happen: DoB. No one expect a timezone in this case. It's an absolute date. Angular's
I expect something similar to this with the date picker |
@dmytro-shchurov thanks for this feedback, I'll try to check this out when I get a chance but PRs with tests are welcome if you have any time. |
Hi I need a absolute date from the date picker. Is there any possibilities. I do not want to convert the date between different time zone |
Hi Guys I Solved this issue u need to change the date to localestring in date directive(date.js) as shown below. //Old Code: controller.$setViewValue(element.datepicker('getDate')); //Change Code: Thanks |
Introduce support for ng-model-options timezone Resolves angular-ui#88, specifically angular-ui#88 (comment)
If i select 07/16/2014 (16th July 2014), it gives a date value as 2014-07-15T18:30:00.000Z. When i convert this string in server side in UTC format, it gives me one day before date.
The text was updated successfully, but these errors were encountered: