/
var
/
www
/
myprog.com.ua
/
server
/
node
/
helpers
/
/var/www/myprog.com.ua/server/node/helpers
mkdir
upload
Name
Size
Mode
Actions
date.js
2557
0644
edit
dl
rm
error.js
651
0644
edit
dl
rm
global.js
1185
0644
edit
dl
rm
log.js
3361
0644
edit
dl
rm
Edit:
/var/www/myprog.com.ua/server/node/helpers/date.js
(2557B)
Date.prototype.toMysqlString = function () { var yyyy = this.getFullYear(); var mm = this.getMonth() < 9 ? "0" + (this.getMonth() + 1) : (this.getMonth() + 1); var dd = this.getDate() < 10 ? "0" + this.getDate() : this.getDate(); var hh = this.getHours() < 10 ? "0" + this.getHours() : this.getHours(); var min = this.getMinutes() < 10 ? "0" + this.getMinutes() : this.getMinutes(); var ss = this.getSeconds() < 10 ? "0" + this.getSeconds() : this.getSeconds(); return `${yyyy}-${mm}-${dd} ${hh}:${min}:${ss}`; }; Date.prototype.toMysqlDate = function () { var yyyy = this.getFullYear(); var mm = this.getMonth() < 9 ? "0" + (this.getMonth() + 1) : (this.getMonth() + 1); var dd = this.getDate() < 10 ? "0" + this.getDate() : this.getDate(); return `${yyyy}-${mm}-${dd}`; }; Date.prototype.toMysqlTime = function () { var hh = this.getHours() < 10 ? "0" + this.getHours() : this.getHours(); var min = this.getMinutes() < 10 ? "0" + this.getMinutes() : this.getMinutes(); var ss = this.getSeconds() < 10 ? "0" + this.getSeconds() : this.getSeconds(); return `${hh}:${min}:${ss}`; }; Date.prototype.microtime = function (getAsFloat) { var s, now, multiplier; if (typeof performance !== 'undefined' && performance.now) { // now = (performance.now() + performance.timing.navigationStart) / 1000; now = (performance.now()) / 1000; multiplier = 1e6; // 1,000,000 for microseconds } else { now = (Date.now ? Date.now() : new Date().getTime()) / 1000; multiplier = 1e3; // 1,000 } // Getting microtime as a float is easy if (getAsFloat) { return now; } // Dirty trick to only get the integer part s = now | 0; return (Math.round((now - s) * multiplier) / multiplier) + ' ' + s; } Date.prototype.between_time = function(time_start, time_end) { let date_now = new Date(); let time_now = `${date_now.getHours()}:${date_now.getMinutes()}`; console.debug(time_start, time_now, time_end); if (time_start != time_end) { if (time_start > time_end) { // 23:30 > 05:30 if (time_now <= time_end && time_now >= '00:00') { // 00:00 > 05:30 return true; } if (time_now >= time_start) { //23:30 > 00:00 return true; } } else { // 05:30 > 23:30 if (time_now >= time_start && time_now <= time_end) { return true; } } } return false; }
Save
cmd:
run