I 've been plagued by time issues. I need your help. please help me!

Source: Internet
Author: User
I 've been plagued by time issues. I need your help. please help me! The storage format of attendance time is incorrect. The bigint I used stores the timestamp.
Limits: swipe your card before half past five am and swipe your card after am. if you are not late or leave early.
Two tables are used: signin and signout.
Problems:
1. how can I determine whether a user is late or leaves early when swiping the card.
2. at the end of the month, how can I obtain all records of his late arrival and departure this month.

It is a headache to compare the time. I hope you will give me some advice. thank you very much. I used thinkphp mysql.

The data table is defined as follows:

Create table ts_user
(Wxname varchar (50) not null primary key,
Name varchar (50) not null,
Telnum char (11) not null unique,
Email varchar (50) unique,
Address varchar (1, 100)
) ENGINE = InnoDB DEFAULT charset = utf8;

Create table ts_signin
(Signid int not null auto_increment primary key,
Wxname varchar (50) not null,
Date timestamp not null,
Location varchar (100) not null
) DEFAULT charset = utf8;

Create table ts_signout
(Signid int not null auto_increment primary key,
Wxname varchar (50) not null,
Date timestamp not null,
Location varchar (100) 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 );

On this side, I am so grateful to have some advice from my predecessors!


Reply to discussion (solution)

strtotime("2015-01-26 09:00:00");strtotime("2015-01-26 17:30:00");

Isn't the timestamp coming?

strtotime("2015-01-26 09:00:00");strtotime("2015-01-26 17:30:00");

Isn't the timestamp coming?


Thank you. someone answered the question. The key is that by the end of each month, I need to obtain the number of late arrivals for this month based on the timestamp of all sign-in for this month. in this case, didn't we generate the timestamp at and every day?

// Obtain the hour of the time. H is in the 24-hour format. judge whether it is late based on H. as for half past five, it will take another minute, in this way, you do not need to generate a date ('H', $ timestamp) every day)

Echo date ('H', strtotime ("09:01:10"); // 09:01:10 echo date ('I', strtotime (""); // 01

Records the data and determines whether it is late or leaves early, and saves it as a new field.
The timestamp at on the current day: strtotime (date ('Y-m-D'). '') and time ().

Create table ts_user (wxname varchar (50) not null primary key, name varchar (50) not null, telnum char (11) not null unique, email varchar (50) unique, address varchar (100) ENGINE = InnoDB DEFAULT charset = utf8; create table ts_signin (signid int not null auto_increment primary key, wxname varchar (50) not null, sdate int (10) not null, chidao int (1) default 0, // 1 late, 0 not late int or bool type can all be edate int (10) not null, zaotui int (1) default 0, // 1: leave early, 0: No leave early, location varchar (100) not null // why is this unknown?) DEFAULT charset = utf8;

Directly select count (chidao) as chidaoa from ts_user, ts_signin, where ts_signin.wxname = ts_user.wxname and (1 month's judgment)
Just like this,
Add 1 piece of data every day, late, early leave, all know, remember to refresh at 12 o'clock every night, no sign in, column is late, or early leave, directly write chidao when inserting data segments, early leave judgment

I have set up a company attendance machine, which is complicated and can be divided into time groups by user departments. However, a user can only belong to one attendance team.

Another setting of the attendance machine is to determine when to start to work and when to start to work. then, it is matched with the commuting time in the attendance shift to determine whether he is late or leaves early.

The statistics at the end of the month are relatively simple and you know that you have obtained all the time that meets the attendance. for example, if you go to work at, you will list all the attendance at work before, and then repeat the date, by the way, we will remove the holiday time. Naturally, we will be late.

Just look at it. I'm not talking.

Create table ts_user (wxname varchar (50) not null primary key, name varchar (50) not null, telnum char (11) not null unique, email varchar (50) unique, address varchar (100) ENGINE = InnoDB DEFAULT charset = utf8; create table ts_signin (signid int not null auto_increment primary key, wxname varchar (50) not null, sdate int (10) not null, chidao int (1) default 0, // 1 late, 0 not late int or bool type can all be edate int (10) not null, zaotui int (1) default 0, // 1: leave early, 0: No leave early, location varchar (100) not null // why is this unknown?) DEFAULT charset = utf8;

Directly select count (chidao) as chidaoa from ts_user, ts_signin, where ts_signin.wxname = ts_user.wxname and (1 month's judgment)
Just like this,
Add 1 piece of data every day, late, early leave, all know, remember to refresh at 12 o'clock every night, no sign in, column is late, or early leave, directly write chidao when inserting data segments, early leave judgment


How can I refresh at every day? please ask. thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.