Getting datetimes from cron format using javascript

Does anyone know of any existing solutions using javascript that can parse a crontab and return all datetime instances between a given start and end date?

ie if i have 0 * * * *, start 24/10/2011 16:00 and end 24/10/2011 19:00 then it will return:

24/10/2011 16:00,
24/10/2011 17:00,
24/10/2011 18:00



You might want to check out Later.js which can parse a Cron expression and calculate the next occurrences.

var schedule = cronParser().parse('* */5 * * * *', true);
var results = later(60).get(schedule, 100, startDate, endDate);

This isn't much help, but it's a start. There are some java (not javascript) and php solutions that have some decent code that you'd want to translate and incorporate if you end up writing this yourself.

Take a look at these two bits of code:



Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.