$date = date_create('2013-10-27');// This is the date that inputed in textbox and that format is (Y-m-d)
$date = date_create('2013-10-10');// and if i click the button i want to force change the 27 to 10?
我应该使用date_modify并执行一些循环,还是有其他方法可以轻松地而不是循环地更改它。
注意:如果你只是想修改对来自提交之日起,每天的值<input>
从<form>
。您可以尝试以下步骤:
$date = '2013-10-27'; // pass the value of input first.
$date = explode('-', $date); // explode to get array of YY-MM-DD
//formatted results of array would be
$date[0] = '2013'; // YY
$date[1] = '10'; // MM
$date[2] = '17'; // DD
// when trigger a button to change the day value.
$date[2] = '10'; // this would change the previous value of DD/Day to this one. Or input any value you want to execute when the button is triggered
// then implode the array again for datetime format.
$date = implode('-', $date); // that will output '2013-10-10'.
// lastly create date format
$date = date_create($date);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句