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

133
Vistas
Is it possible to get a date object out of milliseconds in javascript

I know that a sample date object in javascript is constructed from a string containing the year, month and day. I am building a function that takes a date and number of days as arguments and adds the days to the date and returns a new date object from the same. The approach i used is this:

a) Get the milliseconds from the date object

b) Convert the days to milliseconds

c) Add the two and then derive a date object from the resultant sum. I need a way to get back to the date from the milliseconds. Thank You for your help

function AddDays(x,y){
    //convert the days to milliseconds
    let days_milli=y*24*60*60*1000;
    //get the time in millis from the date
    let days_millis=x.getTime();
    //add the times
    let total=days_milli+days_millis;
    //construct a date object from that
     //this line needs some help
    let date=getDate(total);
    return date;
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Looks like the Date class constructor has overloads to support construction of objects from a string and milliseconds. All i needed to do was to invoke new Date and then put the milliseconds in the parameter part.

function AddDays(x,y){
    //convert the days to milliseconds
    let days_milli=y*24*60*60*1000;
    //get the time in millis from the datw
    let days_millis=x.getTime();
    //add the times
    let total=days_milli+days_millis;
    //construct a date object from that
    let date=new Date(total);
    return date;
}
about 4 years ago · Juan Pablo Isaza 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