How does the front-end js determine that a timestamp is within a certain period of time?

problem description

give me an example. I got the timestamps of the start time and end time through the time selector. But if the timestamp exceeds three months, an error will be reported. Is there any way to judge accurately?

what result do you expect? What is the error message actually seen?

includes all kinds of special cases:
New year"s

, such as December 2018 to February 2019.

Thank you


more than 90 days?
subtract to determine whether it is greater than 90 days 24 days 60 days 60 days 1000


simply judge 90 days as said on the first floor, and use months to judge in detail

var s = new Date('2018-12-05')
var e = new Date('2019-03-06')
s.setMonth(s.getMonth() + 3) < e; // true

For

operation time, you can use momentjs

.

is more reliable than what you write.

for example, if you have a start time, you can get the timestamp three months later by saying:

const start = 1551369600000;

moment(start).add(3, 'months').valueOf();

if you want to know the principle, I suggest you look at the source code.


if the selected time does not include hours, minutes and seconds

s = new Date('2018-12-05')
e = new Date('2019-03-06')
(e.getYear()-s.getYear())*12+(e.getMonth()-s.getMonth()) < 3 || ((e.getYear()-s.getYear())*12+(e.getMonth()-s.getMonth()) === 3 && e.getDate() < s.getDate())
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2bad9-2b308.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2bad9-2b308.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?