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

140
Views
Se muestra una fecha incorrecta

Tengo lo siguiente en un archivo html para mostrar la fecha de hoy.

 <p id="todays-date"> <script> var currentDate = new Date(); var day = currentDate.getDay(); var month = currentDate.getMonth(); var year = currentDate.getFullYear(); var fullDate = day + "/" + month + "/" + year; document.write(fullDate); </script> </p>

En cuanto a que hoy es 23 de septiembre de 2021, 23/9/2021 en Australia, el resultado que obtengo es 4/8/2021.

Cualquier ayuda sería apreciada.

Milton T.

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

0

getDay devuelve el día de la semana actual y getMonth devuelve el mes actual, a partir de 0

Le recomendaría que eche un vistazo a los documentos de API de fecha

 var currentDate = new Date(); var day = currentDate.getDate(); // Returns the day of the month (1–31) for the specified date according to local time. var month = currentDate.getMonth() + 1; // Returns the month (0–11) in the specified date according to local time. var year = currentDate.getFullYear(); var fullDate = day + "/" + month + "/" + year; document.write(fullDate);

about 4 years ago · Juan Pablo Isaza Report

0

  • getDay te da el día de la semana, no la fecha. use getDate en su lugar.
  • getMonth está basado en cero. (enero es 0, no 1). Agregue 1 para obtener el mes convencional basado en uno.
about 4 years ago · Juan Pablo Isaza Report

0

Reemplace getDay con getDate, getDay devuelve el día de la semana 0 representa el domingo y 6 representa el sábado. Así que 4 aquí en tu pregunta representa el jueves.

 var currentDate = new Date(); var day = currentDate.getDate(); var month = currentDate.getMonth(); var year = currentDate.getFullYear(); var fullDate = day + "/" + month + "/" + year; document.write(fullDate);

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!