Skip to content
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

Date format during output #315

Open
jcloutz opened this issue Dec 9, 2016 · 1 comment
Open

Date format during output #315

jcloutz opened this issue Dec 9, 2016 · 1 comment

Comments

@jcloutz
Copy link

jcloutz commented Dec 9, 2016

I am having a problem with this module. When selecting a date on an empty field it works fine.

If I select Date Dec 22, 2016 will format to 12-22-16 in the field and "Thu Dec 22 2016 00:00:00 GMT-0500 (EST)" in the scope.

If I pre-propulate the field with ng-model and value "Thu Dec 22 2016 00:00:00 GMT-0500 (EST)" the module won't read the date and format the string. It just outputs as Thu Dec 22 2016 00:00:00 GMT-0500 (EST)

If i try to pre-populate the field with this format "2016-12-08T05:00:00.000Z" it works fine, but the datepicker won't output that format.

<input type="text" date-time timezone="UTC" min-view="date" format="M-d-yy" 
max-view="date" placeholder="Start Date" ng-model="request.expected_start_date">

In the photo the field on the left if selected and working properly. The field on the right is pre populated with data that was created by the field previously but won't format it when bound with ng-model.
screen shot 2016-12-09 at 5 01 33 pm

@DanTalash
Copy link
Contributor

This module expects to be provided a moment object, which will be updated as the user selects new dates. If you pass a non-moment object such as a string, then the module will attempt to parse it using moment.js and turn it into a moment object.

Therefore, if you need to display the selected dates in a specific format in your scope, you should use the moment().format(); function to get an appropriately formatted string to display.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants