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

362
Views
Firebase date type field conversion

I am receiving data from firestore in the below format of the field whose type is Date.

{
    "seconds": 1642512053,
    "nanoseconds": 303000000
}

Above value is saved in firestore as

January 18, 2022 at 6:58:19 PM UTC+5:30

I want to display the value in dd/mm/yyyy hh:mm AMPM; however toDate, DatePipe, formatDate... none method works. I did string conversion and then converted it to date from seconds which is too much tedious.

Has anyone faced a similar problem and any short-cut trick?

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

0

Those pipes take milliseconds. You could do something like this:

class:

  data = {
    "seconds": 1642512053,
    "nanoseconds": 303000000
  };

html:

{{ data.seconds * 1000 + data.nanoseconds / 1000000 | date: 'dd/mm/yyyy hh:mm a' }}

Which at the time of writing this outputs: 18/20/2022 08:20 AM.

Here's a stackblitz showcasing it:

https://stackblitz.com/edit/angular-c2u4ms?file=src%2Fapp%2Fapp.component.html

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!