I am working in Codeigniter. I have a view, book.php, with a js file, frontend_book.js, running behind it containing a function to sync the calendar.
Snippet from front
You can't make js run from the command line. It only runs in browsers and other environments set up to execute it. Everything you want to do you'll have to do in PHP or another language that runs on the command line.