寻找PHP库以口头方式呈现cron表达式

时间:2016-11-07 16:00:16

标签: php cron

您能否建议 PHP库或至少代码段将Cron表达式字符串转换为口头陈述?

例如:

"5 4 * * *" -> "At 04:05."
"5 4 * 2 SUN" -> "At 04:05 on Sunday in February."

1 个答案:

答案 0 :(得分:0)

由于我无法在任何地方找到这样的PHP库,我决定自己创建它:https://github.com/sivaschenko/utility-cron

用法:

$expression = \Sivaschenko\Utility\Cron\ExpressionFactory::getExpression('5 4 8 * *');

echo $expression->getVerbalString(); // "At 04:05, on 8th day of month."