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

150
Views
Cómo cambiar la marca de tiempo en javascript

Tengo esa cosa escrita en JS que pone una marca de tiempo en los datos de un sensor para almacenarlos en una base de datos. Mi problema es: la marca de tiempo es de 2 horas antes.

Entonces, me gustaría saber cómo agregar dos horas en el script para que escriba la marca de tiempo correcta en la base de datos.

Gracias !

 var sqliteTimeStamp = Math.round(Date.now() / 1000); //converting to seconds instead of milliseconds epoch var theDevice = "growtent"; var theSensor = "t01"; var d = new Date(); var epoch = d.getTime(); var theSQL = "INSERT INTO sensor_data (device,sensor,value,epoch) VALUES " theSQL = theSQL + "('" + theDevice + "', '" + theSensor + "', '" + msg.payload + "', " + epoch +");"; msg.topic = theSQL; // Update the status with current timestamp var now = new Date(); var yyyy = now.getFullYear(); var mm = now.getMonth() < 9 ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based var dd = now.getDay() < 10 ? "0" + now.getDate() : now.getDate(); var hh = (now.getHours() +2) < 10 ? "0" + now.getHours(): now.getHours(); var mmm = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes(); var ss = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds(); node.status({ fill: "blue", shape: "ring", text: "Last update: " + dd + "." + mm + "." + yyyy + " " + hh + ":" + mmm + ":" + ss }); return msg;
about 4 years ago · Santiago Gelvez
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!