Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
Date not working in Typescript but working in browser console

I get this error Supplied parameters do not match any signature of call target. when I try to do this in my TypeScript file in Angular2.

console.log(Date(this.field.sowing_date));

If I execute the same thing in the Chrome Debugger I don't get any problem.

Do you know what is?

I am using:

"@angular/core": "^2.4.0" "@angular/cli": "^1.0.0-rc.4", "@angular/compiler-cli": "^2.4.0",

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You cannot pass a parameter to Date when you don't use it as a constructor (without new):

In JavaScript:

Date(); // returns current date as string
Date("1/1/2017"); // ignores the parameter and returns the current date as string

TypeScript rightfully complains because Date(param) is not a valid way to call Date.

You can use Date in TypeScript like:

let currentDateAsString : string = Date(); // if you want the current date string
let parsedDate: Date = new Date(this.field.sowing_date); // if you want to parse it.

MDN documentation on Date which explains the ways Date can be used: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda