Reputation: 13
i want to pass variable in date function. it works while passing only one variable but if i pass two variable one for month and other for year then it does not work Please resolve
<?php
$m = 'June';
$y = '2011';
echo $cutoff = date('m-d-Y', strtotime( $m . '01' . ' 2011'));
echo '<br>';
echo $nono = date('m-t-Y', strtotime( $m . '01' . $y));
?>
Upvotes: 1
Views: 126
Reputation: 1829
change
echo $nono = date('m-t-Y', strtotime( $m . '01' . $y));
to
echo $nono = date('m-t-Y', strtotime( $m . ' 01 ' . $y));
Upvotes: 0
Reputation: 1345
You have an error in your parameters, you need to add a space between day and year :
Not working
echo $nono = date('m-t-Y', strtotime( $m . '01' . $y));
Working :
echo $nono = date('m-t-Y', strtotime( $m . '01 ' . $y));
Upvotes: 0
Reputation: 1272
You might want to add space to your parameter
echo $nono = date('m-t-Y', strtotime( $m . ' 01 ' . $y));
Upvotes: 2