In MySQL I usually use the int type to store the time. The int type is only 11 bits.
But in JS we can usually use
var nowdate=date.now ();
To get the current time. JS is 13 bits. The last three digits represent the number of milliseconds. We can do simple processing to record the current time (accurate to the second) in case the time requirement is not very strict.
// gets the current time stamp function () { return parseint (Date.now ()/+);}
/** * Formatted date * @param {[type]} date [description] * @param {[type]} pattern [description] * @return {[Type]} [Description]*/Date.format=function(date, pattern) {if(!date) {Date=NewDate; } Else { if(!isDate (date)) {Date=Newdate (date); }} pattern= Pattern | | ' Yyyy-mm-dd '; vary =date.getfullyear (). toString (); varn \{m:date.getmonth ()+ 1,//MonthD:date.getdate (),// DayH:date.gethours (),//HourM:date.getminutes (),//minuteS:date.getseconds ()//Second }; Pattern= Pattern.replace (/(y+)/ig,function(A, b) {returnY.substr (4-math.min (4, b.length)); }); for(varIincho) {pattern= Pattern.replace (NewRegExp (' (' + i + ' + ') ', ' G '),function(A, b) {return(O[i] < && b.length > 1)? ' 0 ' +O[i]: o[i]; }); } returnpattern;}
/* * * Get date and time * @param {[Type]} date [description] * @return {[type]} */function (date) { // return Php.date ("y-m-d h:m:s", date); return Date.format (date *, "Yyyy-mm-dd hh:mm:ss");}
This allows you to store time in a simple type such as int.
Storage of time when node and MySQL mate