Attendance time storage format problem. I used the bigint to store the timestamp.
Limit: Credit card before 9 in the morning, credit card after 5:30, counted as not late and did not leave early.
Two tables were used for card check-in and swipe-back: Signin and SignOut.
The problems encountered are:
1. How can I determine whether he is late or early when the user has a credit card?
2. At the end of the month, how can I get all the records of his late and early departures this month?
It feels like a headache to compare time. Also hope that the predecessors pointed to me, thank you very much. I used the thinkphp MySQL.
The data table is defined as follows:
CREATE TABLE Ts_user
(wxname varchar () NOT NULL primary key,
Name varchar (NOT NULL),
Telnum Char (one) is not null unique,
Email varchar (unique),
Address varchar (100)
) Engine=innodb DEFAULT Charset=utf8;
CREATE TABLE Ts_signin
(Signid int NOT NULL Auto_increment primary key,
Wxname varchar () NOT NULL,
Date timestamp NOT NULL,
Location varchar (+) NOT NULL
) DEFAULT Charset=utf8;
CREATE TABLE Ts_signout
(Signid int NOT NULL Auto_increment primary key,
Wxname varchar () NOT NULL,
Date timestamp NOT NULL,
Location varchar (+) NOT NULL
) DEFAULT Charset=utf8;
ALTER TABLE Ts_signin add foreign key (Wxname) references Ts_user (wxname);
ALTER TABLE Ts_signout add foreign key (Wxname) references Ts_user (wxname);
I think on this side, can get the guidance of senior, thank you!
Reply to discussion (solution)
Strtotime ("2015-01-26 09:00:00"); Strtotime ("2015-01-26 17:30:00");
Is the time stamp coming?
Strtotime ("2015-01-26 09:00:00"); Strtotime ("2015-01-26 17:30:00");
Is the time stamp coming?
Thank you, finally someone answered. The point is, at the end of each month, I need to get the number of times I'm late for this month based on the timestamp of all the check-ins this month, so I'm not going to generate a 9-point and a 17:30-time stamp every day?
Get the hour of time, H is 24 hours according to the H to determine whether late, as for the 5:30, and then compare the minutes can be, so that you do not have to generate a daily timestamp date (' H ', $timestamp)
echo Date (' H ', Strtotime ("2015-01-27 09:01:10")); 9 -point echo Date (' I ', Strtotime ("2015-01-27 09:01:10"));//01
Record data while judging late and early leave, and save as a new field
Timestamp at 9 o ' Day: strtotime (' y-m-d '). ' 09:00 ') compare to Time ()
CREATE TABLE Ts_user (wxname varchar () NOT NULL primary key, name varchar (a) not null,telnum char (one-by-one) not NULL Unique,em AIL varchar (unique,address varchar) engine=innodb DEFAULT charset=utf8;create table ts_signin (Signid int not Null Auto_increment PRIMARY KEY, Wxname varchar (1) NOT NULL, Sdate Int (ten) not Null,chidao int (1) default 0, //0 No late int or bool type all line Edate int (ten) not null,zaotui int (1) default 0,//1 early, 0 not early, location varchar (+) NOT NULL //What's this for? Don't know) DEFAULT Charset=utf8;
Direct select COUNT (Chidao) as Chidaoa from Ts_user,ts_signin, where Ts_signin.wxname =ts_user.wxname and (1 months of judgment)
Just like this, okay?
Add 1 data per day, late, leave early, all know, remember in every night 12 o'clock refresh, no sign-in, listed as late, or leave earlier, insert data section when directly written Chidao, leave to judge
I set up enough to the company's attendance machine, more complex, but also according to the user sub-department, Sub-time group; But overall, a user can only belong to a team of attendance and scheduling.
Time Machine also has a set, that is when to start judging for work, when to start judging for work, and then with the attendance schedule inside the commute time, or judge whether he was late or early.
The end of the month is relatively simple, know to get all the time to meet the attendance, such as you 9:00 to work, you put all the work attendance earlier than 9:01 minutes of attendance all listed, and then cycle the date, the way to remove the holiday time, natural, late came out
Look, I'm not talking.
CREATE TABLE Ts_user (wxname varchar () NOT NULL primary key, name varchar (a) not null,telnum char (one-by-one) not NULL Unique,em AIL varchar (unique,address varchar) engine=innodb DEFAULT charset=utf8;create table ts_signin (Signid int not Null Auto_increment PRIMARY KEY, Wxname varchar (1) NOT NULL, Sdate Int (ten) not Null,chidao int (1) default 0, //0 No late int or bool type all line Edate int (ten) not null,zaotui int (1) default 0,//1 early, 0 not early, location varchar (+) NOT NULL //What's this for? Don't know) DEFAULT Charset=utf8;
Direct select COUNT (Chidao) as Chidaoa from Ts_user,ts_signin, where Ts_signin.wxname =ts_user.wxname and (1 months of judgment)
Just like this, okay?
Add 1 data per day, late, leave early, all know, remember in every night 12 o'clock refresh, no sign-in, listed as late, or leave earlier, insert data section when directly written Chidao, leave to judge
12 o ' Day refresh how to brush it, ask, thank you Ah!