Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

208
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda