我无法将随机天数小时和秒添加到当前日期。
这是我的代码 -
$randnos=rand(0,30);
$randhrs=rand(00,24);
$randmin=rand(00,60);
$randsec=rand(00,60);
$newTime = date("d/m/Y H:m:s",strtotime(" +'.$randnos.' days" . " +'.$randhrs.' Hours". " +'.$randmin.' minutes". " +'.$randsec.' seconds"));
update_post_meta($post_id,'test',$newTime);
答案 0 :(得分:2)
你的引号都搞砸了。
$randnos=rand(0,30);
$randhrs=rand(00,24);
$randmin=rand(00,60);
$randsec=rand(00,60);
$newTime = date("d/m/Y H:m:s",strtotime("+$randnos days +$randhrs hours +$randmin minutes +$randsec seconds"));
update_post_meta($post_id,'test',$newTime);
答案 1 :(得分:2)
<强>一衬垫强>
echo date('Y-m-d h:i:s', strtotime('+' .rand(30, 60 * 60 * 24 * 3).' seconds'));
答案 2 :(得分:1)
public void ChercheStextBox_TextChanged(object sender, EventArgs e)
{
//NASSIM LOUCHANI
BindingSource bs = new BindingSource();
bs.DataSource = dataGridView3.DataSource;
bs.Filter = string.Format("CONVERT(" + dataGridView3.Columns[1].DataPropertyName + ", System.String) like '%" + ChercheStextBox.Text.Replace("'", "''") + "%'");
dataGridView3.DataSource = bs;
}
中使用的string
中的问题。
strtotime()
首先使用随机数据创建字符串,然后插入$randnos=rand(0,30);
$randhrs=rand(00,24);
$randmin=rand(00,60);
$randsec=rand(00,60);
$str = ' +'.$randnos.' days +'.$randhrs.' Hours +'.$randmin.' minutes +'.$randsec.' seconds';
$newTime = date("d/m/Y H:m:s",strtotime($str));
。
答案 3 :(得分:0)
RewriteRule ^courses/([a-zA-Z0-9-_]+)/(0-9-]+)/?$ filename.php?param1=$1¶m2=$2 [QSA,L]