Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
React Native Community DateTimePicker value.getTime no está definido

Hola chicos, tengo algunas preguntas sobre la versión comunitaria de RN DateTimePicker ( https://github.com/react-native-datetimepicker/datetimepicker#value-required )

En primer lugar mi código:

Estado:

 activityDate: todaysDate, (just a JS new Date()) showDatePicker: false

Función de alternar:

 showDatePickerHandler = () => { this.setState({ showDatePicker: !this.state.showDatePicker }) }

Código del selector de fecha y hora:

 <Button onPress={this.showDatePickerHandler} title="Open"/> <> { this.state.showDatePicker && ( <DateTimePicker // style={{width: "60%"}} value={this.state.activityDate} placeholderText="Pick your Date" onChange={(event, date) => { this.resetSOFT() this.setState({ // activityDate: date, activityDate: Moment(date).format("YYYY-MM-DD"), checked: false, } ) }} /> )} </>

Esto es lo que estoy experimentando:

  • Cuando abro DatePicker y luego elijo una fecha y presiono Ok (o cancelar), mi aplicación se vuelve a cargar con este error: TypeError: value.getTime no es una función. (En 'value.getTime()', 'value.getTime' no está definido) : el valor se establece en new Date(), por lo que es raro

  • ¿Hay alguna manera de establecer un formato para todo el componente DateTimePicker? algo como format = "YYYY-MM-DD" y luego debería usar este formato para la fecha

Estaba usando: https://github.com/xgfe/react-native-datepicker antes, que tenía algunas buenas funciones de formateo y una manera fácil de manejar fechas, pero como tiene errores en IOS y no tiene mantenedor, quería cambiar.

Editar: en mi primera pulsación, se ve bien. Obtengo una fecha, pero cuando la abro nuevamente, la aplicación falla y la vuelve a cargar. ¿Cómo puedo cerrar el Selector de manera segura? ¿Es suficiente establecer el estado de showDatePicker en falso en onChange?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Solo puede establecer un new Date() como value del componente DateTimePicker .

Puede mostrar la fecha en el formato requerido en otro componente como se muestra a continuación.

 <> {this.state.showDatePicker && ( <DateTimePicker style={{height: 0}} value={this.state.activityDate} placeholderText="Pick your Date" onChange={(event, date) => { this.resetSOFT() this.setState({ activityDate: date, checked: false, showDatePicker: false }) }} /> )} <TouchableOpacity style={{padding:20, width:'80%', alignItems:'center', justifyContent:'center'}} onPress={()=>showDatePickerHandler()}> <Text>{Moment(date).format("YYYY-MM-DD")}</Text> </TouchableOpacity> </>
about 4 years ago · Juan Pablo Isaza Report

0

reemplace Value.getTime por Date.perse(value) en node_Modules en node_modules/@react-native-community/datetimepicker/src en

1.DatatimePicker.android.js línea No: 88,

2.DatatimePicker.ios.js línea No: 69

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!