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

207
Views
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 answers
Answer question

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 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!