title: Extract Month and Year only from DateTimePickerModal react native
body: <p>I want to extract Month and year from the picker DateTimePickerModal for credit card expiry selection for my application. The user will click on the dropdown icon and on click it will pop up the calendar. On selection of date, it will set it to the input text. Currently it is coming in this format (2020-11-13T12:52:09.002Z).</p>
  <p>Below is my code</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React, { useState } from "react";
  import {
    View,
    Text,
    StyleSheet,
    TextInput,
    Button,
    TouchableOpacity,
  } from "react-native";
  import { DrawerActions } from "@react-navigation/native";
  import CustomHeaderBar from "../components/CustomHeaderBarComponent";
  import ButtonComponent from "../components/ButtonComponent";
  import DateTimePickerModal from "react-native-modal-datetime-picker";
  import { Entypo } from "@expo/vector-icons";
  
  const PaymentScreen = ({ navigation }) =&gt; {
    const [isDatePickerVisible, setDatePickerVisibility] = useState(false);
    const [dateText, setDateText] = useState("");
  
    const showDatePicker = () =&gt; {
      setDatePickerVisibility(true);
    };
  
    const hideDatePicker = () =&gt; {
      setDatePickerVisibility(false);
    };
  
    const handleConfirm = (date) =&gt; {
      setDateText(JSON.stringify(date));
      console.warn(date);
      hideDatePicker();
    };
  
    return (
      &lt;View style={styles.container}&gt;
        &lt;CustomHeaderBar
          label="Payment"
          onPress={() =&gt; {
            navigation.dispatch(DrawerActions.toggleDrawer());
          }}
        /&gt;
        &lt;View style={styles.RatingView}&gt;
          &lt;View style={styles.WrapperView}&gt;
            &lt;Text style={styles.PaymentText}&gt;$ 250.00&lt;/Text&gt;
          &lt;/View&gt;
        &lt;/View&gt;
  
        &lt;View style={styles.lowerHalfStyle}&gt;
          &lt;Text style={styles.TextStyle}&gt;Payment Method&lt;/Text&gt;
          &lt;View style={styles.MarginFromTop}&gt;
            &lt;TextInput
              style={styles.TextInputStyle}
              placeholder="Card No"
            &gt;&lt;/TextInput&gt;
  
            &lt;View style={{ flexDirection: "row" }}&gt;
              &lt;TextInput
                style={styles.TextInputStyle}
                placeholder="Expiry Date (MM/YY)"
                value={dateText}
              &gt;&lt;/TextInput&gt;
              &lt;TouchableOpacity onPress={showDatePicker}&gt;
                &lt;Entypo name="chevron-down" size={24} color="#000000" /&gt;
              &lt;/TouchableOpacity&gt;
              &lt;DateTimePickerModal
                isVisible={isDatePickerVisible}
                mode="date"
                onConfirm={handleConfirm}
                onCancel={hideDatePicker}
              /&gt;
            &lt;/View&gt;
  
            &lt;TextInput
              style={styles.TextInputStyle}
              placeholder="CVC"
            &gt;&lt;/TextInput&gt;
          &lt;/View&gt;
          &lt;View style={styles.MarginFromTop}&gt;
            &lt;ButtonComponent label="PAY" /&gt;
          &lt;/View&gt;
        &lt;/View&gt;
      &lt;/View&gt;
    );
  };
  export default PaymentScreen;</code></pre>
  </div>
  </div>
  </p>
  <p>Please guide how to achieve this functionality, want to display it in format MM/YY as per screenshot below</p>
  <p><a href="https://i.stack.imgur.com/tOXCx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tOXCx.png" alt="enter image description here" /></a></p>