I am using angular DateTime Picker. i am using $uibModel to show a pop up and couple of fields are there for updatind data. I am using
bootstrap-ui-datetime-picker
this date to add atetime picker. I am passing JSON and I am displaying in corresponding fields. My date format is
2016-02-19T10:55:33+00:00
and My format I am using in input field is
datetime-picker="yyyy-MM-ddTHH:mm:ss:sssZ"
as per the docs. But I am not getting the model reflected in the text box. If I remove the format in input field I get the model displayed there. Why is this happening? i have given the same format as the value to format input. Thanks.
Related
I use Redux Form and react-datepicker
It works very nice, and I would like to get it work ideally according to my needs.
I need to show the date in localized format (let's say DD/MM/YYYY), and in the same time save value attribute of the input in static format ("YYYY-MM-DD").
I could add a hidden input with such value format, but if it's possible to avoid it using datepicker customization, it would be great!
Thanks for your advice in advance.
UPD:
Take a look on screenshots:
This is how it works now (nothing has to be changed here).
And value is synchronized with the locale. I want to keep the locale to present my date in the locale format for the user, and keep the format unchanged ("YYYY-MM-DD" forever) for the back end.
Here is the link to codesandbox.
You can use state and moment.js package to have date in several formats.
EDIT: the key thing is redux form. Datepicker is just view that can show exactly what you need. So, what you can do is: change redux form field value (or what you are using) and just have another state field (let's say 'dateForDatepicker') which value you'll pass to datepicker.
GOOD SOLUTION: https://stackoverflow.com/a/42726079/7479959
I am trying to display initial values on my redux form when it first load. Every fields work except the date input field. I tried to use moment to format string (YYYYMMDD) to MM/DD/YYYY and it's not working. No matter how I formatted, the field fail to display and instead showing the default place holder character mm/dd/yyyy until I selected a date. I am using the default redux-form input component date type. How should I do this right? Appreciate for any help.
When you are setting the initial date in your state, you need to provide it as per ISO-8601 standards, so YYYY-MM-DD, i.e. 2018-08-22 for 22nd August 2018.
I have never used redux-form library before, but I found a codesandbox example in their guide, and managed to get it to work here by just relying on them having followed the ISO standard. Feel free to play around with it.
I'm trying to implement a feature for a form where:
1. I display a date string in the format mm-dd-yyyy
2. User is allowed to edit the form, and the date string would remain in the format mm-dd-yyyy
3. When the user submits the form, the date string must be in the format yyyy-mm-dd.
3. The original format of the date string is yyyy-mm-dd.
I would prefer to achieve this somehow by means of a directive rather than calling a function everytime a user submits a form, was wondering if there were any thoughts on a good way to do this?
I've given angular-ui-mask a look but am not sure if this would help me so much for this case.
Thanks!
Basically I have an editable-date field in my angular app which is shown to user like:
mm/dd/yyyy when the field is not selected
But I want to show to user as: dd/mm/yyyy. Where to set the format for display to user when field is not selected ?
Make a custom directive that require ngModel and changes the model view value.
(this i would do in case i'm working with breeze entities for example, and i don't want to actually change the value or affect the entityState)
If that doesn't bother you, than use moment to format the date how you like.
(moment is a powerful js library with advanced format options)
I need to set the kendo angular datepicker input field to a date value with a particular date format when my angular model is holding a string date value like "2014-08-21T11:27:04". can anyone please help?
You can use a date filter to change the model with defined date/time format in JavaScript or in HTML templates.
There is a lot of elements which can be used to compose a date string, so visit the official docs, where everything is well described.