I am looking to make a small PHP-CLI tool that will tell me if a date that I input, is a weekend day. I currently have the following script, which achieves some of this goal:
<?php
function isWeekend($date) {
return (date('N', strtotime($date)) >= 6);
}
var_dump(isWeekend('2014-10-29'));
?>
It currently works well (outputs true or false), but I must update the source each time I want to test a date. It would be easier if I could prompt for date (user input), and then use that input to calculate the date, preferably without using HTML elements, as I am currently running the script via the CLI.
Has anyone else managed to achieve what I was looking to do? I don't need validation, as its a tool that only I will use, and I will be sure to use the correct date structure each time I use it.