Link to home
Start Free TrialLog in
Avatar of Rama Tito
Rama TitoFlag for Malaysia

asked on

Time different while select data - timestamp

Hi,

In node red, while i insert the - timestamp datatype its work perfectly. while try to select data with the time stamp, its display different time.

Data insert in mariadb ----> 2018-09-19 23:47:26

While select data
if (Device > 0)
    msg.topic ="Select DeviceId, Line, outPIN, count,Time FROM mytab LIMIT 1";

return msg;

Open in new window


While try pull data out of mariadb the data timestamp show --> 2018-09-19 00:20:00
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

What does your insert statement look like?

We would need to see what was sent as well as what is in the DB.
Avatar of Rama Tito

ASKER

var dt = new Date();
var year = dt.getFullYear();

var month = dt.getMonth()+1;
month = ("0" + month).slice(-2); 

var date1 = dt.getDate();
date1 = ("0" + date1).slice(-2)

var hour = dt.getHours();
hour = ("0" + hour).slice(-2);

var minute = dt.getMinutes();
minute=("0" +minute).slice(-2);

var sec = dt.getSeconds();
sec=("0" + sec).slice(-2);

var dtout = year+"-"+month+"-"+date1+" "+hour+":"+minute+":"+sec;


if(msg.payload == 1)
{
    //msg.topic ="Production/SSL";
    msg.payload = {
                    Device_ID : 2,
                    Line_ID : 1,
                    GPIO : 7,
                    Count : 1, 
                    dtout : dtout
                    
    }
   
}

msg.topic = "INSERT INTO mytab (DeviceId,Line,outPIN,count,Time) VALUES (?,?,?,?,?)";           
msg.payload = [msg.payload.Device_ID, msg.payload.Line_ID  , msg.payload.GPIO, msg.payload.Count, msg.payload.dtout];

return msg;

Open in new window

What do you get if you put this on line 20
console.log(dtout);

Open in new window

2018-09-20 16:30:24   which is same has my local machine
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial