我正在创建一个简单的应用程序(PHP 和 MYSQL)来收集有关事件的信息,并且我想在日期收集部分中加入自然语言处理。我偶然发现了 date.js (www.datejs.com),它看起来很合适,但我不确定如何将它合并到输入表单中,然后将转换后的字符串作为变量传递给数据库.
有没有人在 PHP 环境中成功实现了这一点(或有更好的解决方案)?
您可以使用 php 函数 [strtotime][1] 执行相同的操作
<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
?>
[1]:http: //www.php.net/manual/en/function.strtotime.php strtotime