select_date.js
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const {remote, ipcRenderer} = require("electron");
const closeBtn = document.getElementById("closeBtn");
closeBtn.addEventListener("click", () => {
let window = remote.getCurrentWindow();
window.close();
});
var mysql = require('mysql');
//mysql 연동
var connection = mysql.createConnection({
user:'root',
password:'1234',
database : 'dataextraction'
})
connection.connect();
//최대 선택 가능 날짜 설정
var today = new Date();
document.getElementById("start_date").max = today.toISOString().substring(0, 10);
document.getElementById("end_date").max = today.toISOString().substring(0, 10);
const btn = document.getElementById("submit");
btn.addEventListener("click", () => {
var start_date = new String(document.getElementById("start_date").value);
var end_date = new String(document.getElementById("end_date").value);
var st = new Date(start_date);
var et = new Date(end_date);
st.setHours(st.getHours());
et.setHours(et.getHours() + 24);
et.setMilliseconds(et.getMilliseconds() -1);
var sTimestamp =st.getTime();
var eTimestamp =et.getTime();
connection.query('SELECT * FROM photo WHERE date_added > "'+sTimestamp+'" AND date_added <= "'+eTimestamp+'" ORDER BY date_added', function(error, results, fields){
if(error){
}
else{
var arg={
result : results,
start : start_date,
end : end_date
}
ipcRenderer.send(
"photo",
arg
);
let window = remote.getCurrentWindow();
window.close();
}
} )
});