I'm trying to pass a timestamp value in MySQL, so I'm trying to do this:
database.query(`INSERT INTO bookrent (userID, bookID, bookRented , TimeStart, TimeEnd) VALUES ('${userBoughtItID}','${bookCheckID}',true, CURRENT_TIMESTAMP() ,CURRENT_TIMESTAMP() 30)`,(req1,res1) => {});
My variables inside the query works fine but every time I try to add " 30" seconds to TimeEnd column it gives me zeros, but sometimes it gives me the correct timestamp.
Also I'm trying to figure out why MySQL shows timestamp column as date time.
I'm using Node server.
CodePudding user response:
This might work, although I have not tested it.
database.query(`INSERT INTO bookrent (userID, bookID, bookRented , TimeStart, TimeEnd) VALUES ('${userBoughtItID}','${bookCheckID}',true, CURRENT_TIMESTAMP() , ADDTIME(CURRENT_TIMESTAMP(), "30"))`,(req1,res1) => {});