Home > front end >  Start time and end time
Start time and end time

Time:03-25

I now have a demand, need after the new start time and end time in LayUI input insurance aging click save again, after the implementation of new prescription format for starting time - termination time, now my insurance aging fields in the database as a timestamp type, now how to deal with in order to realize new? Entity class, every comment, the background of aging fields did conversion processing,


CodePudding user response:

Didn't see you mean... Since you said a background, has the entity class, that should be added, you ask is this?

CodePudding user response:

I mean the insurance of a field in the database, it represents the start time and end time, in the database for the timestamp type, I now click save after a fault,

CodePudding user response:

Tip said request date/time types, you the whole date together, the two cannot be changed,

Is calculated according to the start-stop time of limitation of insurance should not be made with a string

CodePudding user response:

Then you should ask: "2021-03-24" how to date format into a timestamp...
Can you not to say that the background has been done into processing...
Front end use: the Date. The parse ()
 
The console. The log (Date. Parse (' 2021/03/24 00:00:00 '));

CodePudding user response:

Hello World reference 3 floor, response:
prompt said requirements date/time types, you this two date together, cannot be changed,

Is calculated according to the start-stop time of limitation of insurance should not make a string with it
or you look carefully, I am never look, thought is the format of the questions he said...

CodePudding user response:

Timespan is similar to the 1616579585678 such long plastic, but you put into a similar 'XXXX - xx, xx, xx, xx, XXXX' strings, you should be at the front desk and start time between the end of the difference between the timespan, and in the database is ok, here is a jquery timespan library, you can look at, ready-made,
https://github.com/mstum/TimeSpan.js

CodePudding user response:

Or consider this, just find online, didn't test, the consequence is proud

Function DateDiff (sDate1, sDate2) {//sDate1 and sDate2 is yyyy - MM - dd format string
Var aDate oDate1, oDate2 iDays, ihours, iminutes, iseconds;
ADate=sDate1. Split (" - ");
ODate1=new Date (aDate [1] + '-' + aDate [2] + '-' + aDate [0]).//convert MM - dd - yyyy format
ADate=sDate2. Split (" - ");
ODate2=new Date (aDate [1] + '-' + aDate [2] + '-' + aDate [0]).
Var timeSpan={};
Var TotalMilliseconds=Math. Abs (oDate1 - oDate2);//the number of milliseconds difference
TimeSpan. Days=parseInt (TotalMilliseconds/1000/60/60/24);
TimeSpan. TotalHours=parseInt (TotalMilliseconds/1000/60/60);
TimeSpan. Hours=timeSpan. TotalHours % 24;
TimeSpan. TotalMinutes=parseInt (TotalMilliseconds/1000/60);
TimeSpan. Minutes=timeSpan. TotalMinutes % 60;
TimeSpan. TotalSeconds=parseInt (TotalMilliseconds/1000);
TimeSpan. Seconds=timeSpan. TotalSeconds % 60;
TimeSpan. TotalMilliseconds=TotalMilliseconds;
TimeSpan. Milliseconds=TotalMilliseconds % 1000;
Return timeSpan.
}
  • Related