xgfe / react-native-datepicker

react native datePicker component for both Android and IOS, useing DatePikcerAndroid, TimePickerAndroid and DatePickerIOS
MIT License
2.12k stars 726 forks source link

DatePicker does not render time with different format #276

Open sanzhardanybayev opened 6 years ago

sanzhardanybayev commented 6 years ago

Issue

When I send formatted date value to date property, DatePicker does not render it in my format! It uses the default component's format!

Expected Behavior

Date picker renders date in my format, rather than in the default

Code

This is what I have:

 <DatePicker
          style={{ alignSelf: 'center', justifySelf: 'center' }}
          mode="date"
          date={moment.utc(this.props.chosenDate).format('L')}
          placeholder="Choose date"
          showIcon={false}
          locale={'ru'}
          format="l"
          minDate="2018-01-01"
          maxDate="2030-12-31"
          confirmBtnText="Choose"
          cancelBtnText="Cancel"
          customStyles={{
            dateInput: {
              borderWidth: 0,
              textAlign: 'center'
            }
            // ... You can check the source to find the other keys.
          }}
          onDateChange={this.props.f}
        />

Environment

  1. react-native -v: 0.55.4
  2. node -v: 10.0.0
  3. npm -v: 6.3.0
  4. target platform: Android | iOS
  5. operating system: Windows 10
sanzhardanybayev commented 6 years ago

Made changes to this repo and made pull request. Please consider accepting it.