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

166
Views
Convert date to string in Angular

I'm working on an Angular webui project. Currently I have to get a value from a data-document.json which is of type date but I need to display it as a string. How would I be able to achieve this?

"FACD_Dispatch_DateTime": "2022-01-19T16:46:03.959",

this is the way that I've been trying:

map(([d]) => {

           let myDate: string;
          if (d?.value) {
            myDate = d.value;
          }

but terminal returns the error: Type 'Date' is not assignable to type 'string'

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

0

well "FACD_Dispatch_DateTime": "2022-01-19T16:46:03.959" is not a Date, but a string. Anyway:

let myDate: Date;
if (d?.value) {
  myDate = d.value;
}

then you can display it in your HTML:

<h1> Day: {{myDate | date:'dd.MM.yyyy'}} Time: {{myDate | date:'HH:mm'}}</h1>
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!