Answers for "react-native date time picker"

1

react-native date time picker

expo install react-native-modal-datetime-picker @react-native-community/datetimepicker

import React, { useState } from "react";
import { Button, View } from "react-native";
import DateTimePickerModal from "react-native-modal-datetime-picker";

const Example = () => {
  const [isDatePickerVisible, setDatePickerVisibility] = useState(false);

  const showDatePicker = () => {
    setDatePickerVisibility(true);
  };

  const hideDatePicker = () => {
    setDatePickerVisibility(false);
  };

  const handleConfirm = (date) => {
    console.warn("A date has been picked: ", date);
    hideDatePicker();
  };

  return (
    <View>
      <Button title="Show Date Picker" onPress={showDatePicker} />
      <DateTimePickerModal
        isVisible={isDatePickerVisible}
        mode="date"
        onConfirm={handleConfirm}
        onCancel={hideDatePicker}
      />
    </View>
  );
};

export default Example;
Posted by: Guest on May-17-2021
1

reactnative timePicker

timePicker in reactNative
Posted by: Guest on April-03-2021
0

date picker react native

import {
  SafeAreaView,
  StyleSheet,
  Text,
  View,
  TextInput,
  Picker,
  Button,
  Image,
  DatePickerIOS,
  TouchableOpacity,
} from 'react-native';
import DatePicker from 'react-native-datepicker';          

<DatePicker
            style={styles.datePickerStyle}
            date={date}
            mode="date"
            placeholder="select date"
            format="DD-MM-YYYY"
            minDate="01-01-2016"
            maxDate="01-01-20900"
            confirmBtnText="Confirm"
            cancelBtnText="Cancel"
            customStyles={{
              dateIcon: {
                //display: 'none',
                position: 'absolute',
                left: 0,
                top: 4,
                marginLeft: 0,
              },
              dateInput: {
                marginLeft: 36,
              },
            }}
          />
Posted by: Guest on July-29-2021

Browse Popular Code Answers by Language