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

109
Views
React.js Epoch timestamp to display only time AM PM

I am doing a personal React.js project. I have a map that gives me as one of the values an Epoch timestamp. I want to display only the time of that timestamp as AM or PM, but I can't figure it out. This is the code:

import { useEffect, useState } from "react";

const Home = () => {
  const [result, setResult] = useState([]);

  useEffect(() => {
    fetch("https://www.betright.com.au/api/racing/todaysracing")
      .then((res) => {
        return res.json();
      })
      .then(
        (data) => {
          setResult(data);
          console.log("data useEffect", data);
        },
        (err) => {
          return console.error(err);
        }
      );
  }, []);
  console.log("result", result);
  return (
    <>
      <h1>Upcoming Racing</h1>
      {Object.entries(result).map(([key, value]) => (
        <table key={key}>
          <thead>
            <tr>
              <th>{key}</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>
                {value.slice(0, 5).map((dog, c) => (
                  <div key={c}>
                    <div>Race name: {dog.Venue}</div>
                    <div>Race number: {dog.Race1.RaceNumber}</div>
                    <div>
                      Advertised date:
                      {Date(dog.Race1.AdvertisedStartTime.slice(6, 19))}
                    </div>
                  </div>
                ))}
              </td>
            </tr>
          </tbody>
        </table>
      ))}
    </>
  );
};

export default Home;

This is a codesandbox link with the whole code and its output.

about 4 years ago · Juan Pablo Isaza
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!