skip to Main Content
             `<View style={styles.dateInput}>
              <Text style={styles.text}>To Date</Text>
              <TouchableOpacity onPress={() => showDatePicker(false)}>
                <TextInput
                  placeholder="Select Date"
                  value={toDate}
                  editable={false}
                  style={styles.dateinput}
                />
              </TouchableOpacity>
            </View>
            <DateTimePickerModal
              isVisible={isDatePickerVisible}
              mode="date"
              onConfirm={handleDateConfirm}
              onCancel={hideDatePicker}
            />`

i want to display current date in place of "Select Date" in placeholder. i have a datepicker input for selcting the date.

2

Answers


  1. You need a state for save toDate value.
    And with dayjs. you can show it ez:

               <View style={styles.dateInput}>
                  <Text style={styles.text}>To Date</Text>
                  <TouchableOpacity onPress={() => showDatePicker(false)}>
                    <TextInput
                      placeholder="Select Date"
                      value={dayjs(toDate).format("DD/MM/YYYY")}
                      editable={false}
                      style={styles.dateinput}
                    />
                  </TouchableOpacity>
                </View>
                <DateTimePickerModal
                  isVisible={isDatePickerVisible}
                  mode="date"
                  onConfirm={handleDateConfirm}
                  onCancel={hideDatePicker}
                />
        
    
    Login or Signup to reply.
  2.    `<View style={styles.dateInput}>
              <Text style={styles.text}>To Date</Text>
              <TouchableOpacity onPress={() => showDatePicker(false)}>
                <TextInput
                  placeholder="Select Date"
                  value={toDate.toDateString()}
                  editable={false}
                  style={styles.dateinput}
                />
              </TouchableOpacity>
            </View>
            <DateTimePickerModal
              isVisible={isDatePickerVisible}
              mode="date"
              onConfirm={handleDateConfirm}
              onCancel={hideDatePicker}
            />`
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search