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

125
Views
How can I add a static timestamp?

I want to add a static timestamp (for a list or social media app for example) using plain javascript. Currently I have it like this:

  const d = new Date();
  const time = d.toLocaleTimeString();

The problem is that when you refresh, it also refreshes the time and sets it to your current time, not the time that the item was posted. How can I fix this?

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

0

use time like this in reactjs, using useState, so wont get updated, you can use time variable,

const [time, setTime] = useState(new Date().toLocaleTimeString());

if(localStorage.getItem("time")){
    setTime(localStorage.getItem("time"))
} else {
    localStorage.setItem("time", time);
    setTime(time)
}
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!