ionic-framework: bug(datetime) - Datetime now returns an object, instead of an ISO string

Ionic version: (check one with “x”) [ ] 1.x [ ] 2.x [x] 3.x

I’m submitting a … (check one with “x”) [x] bug report [ ] feature request [ ] support request

Current behavior: Selecting a date with the datetime and clicking ‘OK’ returns an object to the model instead of an ISO string. According to the docs I should be receiving an ISO string: DateTime Docs

Expected behavior: I expect the datetime to return an ISO string as it did in ionic 2

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below): Cordova CLI: 6.5.0 Ionic Framework Version: 3.0.1-201704062237 Ionic CLI Version: 2.2.1 Ionic App Lib Version: 2.2.0 Ionic App Scripts Version: 1.3.0 ios-deploy version: 1.9.1 ios-sim version: 5.0.13 OS: macOS Sierra Node Version: v6.10.1 Xcode version: Xcode 8.3.1 Build version 8E1000a

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 18 (6 by maintainers)

Most upvoted comments

I agree with @growthclick

I use datetime with formControlName and this saved me:

import { convertDataToISO } from 'ionic-angular/util/datetime-util';

const formatedDate = convertDataToISO(this.form.get('date_field').value);

Any update on this please? I first reported this bug on 7th of April. Thanks

On Wed, Apr 26, 2017 at 11:21 PM, Leonardo Ruhland <notifications@github.com

wrote:

Replying to @jgw96 https://github.com/jgw96:

is this still an issue with ionic-angular 3.1.0 ?

Yes, 3.0.1 release is ok and 3.1.0 release is missing convertDataToISO in DateTime component and has the bug.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/driftyco/ionic/issues/11175#issuecomment-297558168, or mute the thread https://github.com/notifications/unsubscribe-auth/ABb0T1ZZWiY7RDpd4ytvSzc4pNtxBn3lks5rz8NlgaJpZM4M6bBf .

Thanks for the workaround. That might work well with single binding on [ngModel]. I retested with the component inside a form and with correct names but still had the same results.

It looks like the object may be getting passed back in the onChange function without the convertDataToISO() call that is on line 836.

https://github.com/driftyco/ionic/blob/24544e01e150bf59bfc8a6d1cc38b7cdae860c4f/src/components/datetime/datetime.ts#L850

https://github.com/driftyco/ionic/blob/24544e01e150bf59bfc8a6d1cc38b7cdae860c4f/src/components/datetime/datetime.ts#L836