Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

parse crontab line with JavaScript

I have a web form, with text inputs for crontab values (minutes/hours/months/days), and I want to display user the next date of selected crontab task execution. For example, i have a values

20 15 15 * *, and the expected result will be: "Next run: 15.06.2013, 15-20"

Do you know any suitable javascript library?

like image 234
krevedko Avatar asked Jul 12 '26 10:07

krevedko


1 Answers

There is a library called Later.js

which works like this

<!DOCTYPE html>
<html>
<body>
</body>

<script src="https://raw.github.com/bunkat/later/master/later.min.js" type="text/javascript"></script>
<script type="text/javascript">
// create the desired schedule


// calculate the next 5 occurrences with a minimum resolution of 60 seconds, using local time
var s = cronParser().parse('* */5 * * * *', true);
var results = later(60, true).get(s, 20);

document.write('<p>Next Run:' + results[1].toLocaleString() + '</p>');


</script>
</html>

You can check their Example for more information

Best Regards :)

like image 130
Dinever Avatar answered Jul 15 '26 00:07

Dinever



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!