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

101
Views
timestamp to IST reactjs

How to compare the firebase timestamp with Indian Standard Time (IST). We have to compare everything like date and time. If both are equal we should give a message in alert box as Success otherwise alert as not-matchedThis is the image of firebase timestamp

This is the image for IST date

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

0

You can convert the firestore timestamp to javascript timestamp using .toDate() and then convert the js timestamp to the desired timezone - you can use sophisticated moment-timezone library method moment().tz() or the js date library method toLocaleString().

fbTs.toDate().toLocaleString(undefined, { timeZone: 'Asia/Kolkata' }); 

fbTs is the firestore timestamp

For comparison, it is better to convert both the timestamps - the firebase timestamp and the current timestamp in epoch timestamp and compare. getTime() method will get you this. `

if (fbTs.toDate().getTime() === new Date().getTime()) { 
  ...
} else { 
  ...
}

about 4 years ago · Juan Pablo Isaza Report

0

Fetch the date from firebase, and call Date.parse() on it to convert it to an epoch date. Then do the same on your IST date. If you want the current time in an epoch date use Date.now().

Something like this:

const updatedDateEpoch = Date.parse(*YOUR DATE FROM FIREBASE*)

// if you want the current time use this date
const currentEpoch = Date.now()

// IST date to epoch
const istEpoch = Date.parse(*THE IST DATE YOU HAVE*)

// switch currentEpoch to istEpoch if you don't want to use the current time.
if (currentEpoch === updatedDateEpoch){
    alert("Success!")
}else{
    alert("Not matched.")
}
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!