|
- function getRandomTime(startTime, endTime) {
- const start = new Date('2024-03-21T09:01:00');
- const end = new Date('2024-03-21T09:30:00');
- const randomTime = new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
- return randomTime;
- }
- const randomTime = getRandomTime('2024-03-21T09:01:00', '2024-03-21T09:30:00');
- console.log(randomTime);
复制代码
Javascript版本 |
|