Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
Having issue on how to get AM/PM react native code?

I'm currently using this format to obtain time from the API data ( enter image description here)

const d = new Date(eventData.ends_on);
const endTime = `${d.getHours()}:${d.getMinutes()${d.getSeconds()}` 

if i would like to add AM/PM like this enter image description here, How would the format look like in the above code. Pls do help me out.

Below is my code, I would like to implement it in this code:

return (
        <ScrollView style={[GlobalStyle.CustomScrollView]}>
            <HeaderBar3/>
            <Text style={[GlobalStyle.EventTitle]}> Event Details</Text>
            <View style={[GlobalStyle.EventDetailView]}>
                <Image style={[GlobalStyle.EventDetailImage]} source={{uri: eventData.main_image}} resizeMode="contain"/>
                <Text style={[GlobalStyle.EventSubtitle]}>Date:</Text>
                <Text style={[GlobalStyle.EventDate]}>{date}</Text>
                <Text style={[GlobalStyle.EventTime]}>{endTime}</Text>
        </View>
        </ScrollView>
    );
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

One option is to use the toLocaleString method, so you can provide the options you need. To use the default locale just pass an empty array to the function.

Example

const d = new Date()
const time = d.toLocaleString([], {
  hour: 'numeric',
  minute: 'numeric',
  hour12: true
})

console.log(time)

To use it with a predefined date, just change the first line:

const d = new Date(item.ends_on)

More information

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda