这些是常见的strtotime()
格式:
strtotime("now");
strtotime("3 October 2005");
strtotime("+5 hours");
strtotime("+1 week");
strtotime("+1 week 3 days 7 hours 5 seconds");
strtotime("next Monday");
strtotime("last Sunday");
等等。
我需要一个不同格式的代码,我有这样的东西:
$date = strtotime("6 Oct 2014");
$d=date('Y-M-j',$date);
$sql="CREATE DATABASE `".$row['Database'].".$d."`"; //this one creates a database with the current date,which is 6 Oct 2014
$query2=mysql_query($sql,$connect);
一周、两周、一个月或一年后,我想自动删除该数据库,如下所示:
$sql="SHOW DATABASES LIKE '%".date('Y-M-j',strtotime("last ***",$date))."'";
$query=mysql_query($sql,$connect);
$sqlDROP="DROP DATABASE IF EXISTS `".$row."`"; //this one will drop the listed databases above
$queryDROP=mysql_query($sqlDROP,$connect);
我想要的是一种格式,而不是"last*",这将删除旧数据库,我不能使用像上个月、上周、去年这样的格式,因为我有很多数据库,在不同的日期创建,当我创建一个新数据库时,我需要删除旧数据库。
我希望你明白。
你想要的并不存在。没有一个值像您正在寻找的值。你所要做的就是思考,并在你的show查询中找到一些技巧,添加多个strtotime()函数,这样你就可以涵盖每一种会给你带来问题的情况。祝你好运