Known Date: 2013-07-31 plus 12 months 3 months 1 months get the appropriate date
Known Date: 2013-07-31 plus 12 months 3 months 1 months get the appropriate date
How can daniel write php code?
Share to: more
------Solution--------------------
$s = ' 2013-07-31 ';
echo Date ("Y-m-d", Strtotime ("$s +1 month");
------Solution--------------------
Oh, take it for granted
echo Date ("y-m-d\n", Strtotime ("$s +7 month");
Get 2014-03-03
Select Adddate (' 2013-07-31 ', INTERVAL 7 month)
Get 2014-02-28
Obviously, PHP's performance is unsatisfactory.
------Solution--------------------
Mktime can actually meet the requirements.
$t = ' 2013-07-31 ';
echo Date ("Y-m-d", Mktime (0,0,0,date ("M") + 12,date ("D"), Date ("Y")).
';
echo Date ("Y-m-d", Mktime (0,0,0,date ("M") + 3,date ("D"), Date ("Y")).
';
echo Date ("Y-m-d", Mktime (0,0,0,date ("M") + 1,date ("D"), Date ("Y")).
';
Results:
2014-07-31
2013-10-31
2013-08-31
------Solution--------------------
$t = ' 2013-07-31 ';
echo Date ("Y-m-d", Mktime (0,0,0,date ("M") + 2,date ("D"), Date ("Y"));
To 2013-10-01
The most undesirable is: to avoid contradictions