MYSQL Query With Timestamp Long Values
Mukit, Ataul - Mar 29 '18 - - Dev Community
function MySQLTimeStampCompatibleString(timestamp){
return new Date(timestamp).toISOString().substring(0, 19).replace('T', ' ');
}
function queryWithTimestampLongValues(fromTime, toTime) {
var query = "";
if(fromTime && toTime){
query += 'SELECT * FROM user_info WHERE
user_info.created_at > TIMESTAMP("' +
MySQLTimeStampCompatibleString(fromTime) + '") AND
user_info.created_at < TIMESTAMP("' +
MySQLTimeStampCompatibleString(toTime) + '")';
}
return query;
}