title: How to show selected date and time in textinput in react native
body: <p>I am developing a react-native app. And i am using a date time picker in it. My problem is i want to show the selected date and time from the date-time picker in the textInput immediately after selected the date and time ...  how to do that. Here is my code</p>
  
  <pre><code>import React from 'react';
  import { StyleSheet, Text, View, TextInput } from 'react-native';
  import DateTimePicker from 'react-native-modal-datetime-picker';
  
  export default class App extends React.Component {
    constructor(props){
      super(props)
  
      this.state=({ 
  
        isDateTimePickerVisible: false,
        selecteddate:''
      })
    }
  
    _showDateTimePicker = () =&gt; this.setState({ isDateTimePickerVisible: true });
  
    _hideDateTimePicker = () =&gt; this.setState({ isDateTimePickerVisible: false });
  
    _handleDatePicked = (pickeddate) =&gt; {
      day   = pickeddate.getDate();
      month = pickeddate.getMonth();
      year  = pickeddate.getFullYear();
      console.log('A date has been picked: ' + day + '-' + month + '-' + year);
      exdate= day + '-' + month + '-' + year
      this._hideDateTimePicker();
    };
  
    onFocus = () =&gt; {
      this._handleDatePicked();
    }
  
    render() {
      return (
        &lt;View style={styles.container}&gt;
          &lt;Text&gt;Open up App.js to start working on your app!&lt;/Text&gt;
          &lt;TextInput 
          placeholder="placeholder..."
          onFocus={ () =&gt; this._showDateTimePicker() }
          value={this.state.selecteddate}
          /&gt;
          {/* //--------------------------------------DateTimePicker */}
          &lt;DateTimePicker
                        isVisible={this.state.isDateTimePickerVisible}
                        onConfirm={this._handleDatePicked}
                        onCancel={this._hideDateTimePicker}
                        mode={'date'}
                        datePickerModeAndroid={'spinner'}
  
                      /&gt;
              {/* //-------------------------------------- */}
        &lt;/View&gt;
      );
    }
  }
  
  const styles = StyleSheet.create({
    container: {
      flex: 1,
      backgroundColor: '#fff',
      alignItems: 'center',
      justifyContent: 'center',
    },
  });
  </code></pre>