Format the utc time in 15 minutes.

for example, if the
time is 15:55, then 16:00 is displayed.
the time is 16:08, so it shows 16:15.
the time is 16:19, so it shows 16:30.

/ / = split line =
the following is the way I use, which can meet the demand, but I feel that it is very tedious to write, so humbly ask for more convenient way to write ~

.
function formatBeginTime(beginTime){
    let time = new Date(beginTime);
    let minute = time.getMinutes();
    if (minute > 0 && minute <= 15) {
        time.setMinutes(15);
    }
    if (minute > 15 && minute <= 30) {
        time.setMinutes(30);
    }
    if (minute > 30 && minute <= 45) {
        time.setMinutes(45);
    }
    if (minute > 45) {
        time.setMinutes(0);
        time.setHours(time.getHours()+1);
    }
    return time.getTime();
}
Sep.07,2021

  

take out the minutes, 15 and 15 + 15 to see who is closest

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-1eaeb31-21f5.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-1eaeb31-21f5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?