1

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)); 
?> 

3 Answers 3

2

You might want to add space to your parameter

echo $nono = date('m-t-Y', strtotime( $m . ' 01 ' . $y));
Sign up to request clarification or add additional context in comments.

Comments

0

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)); 

Comments

0

change

echo $nono = date('m-t-Y', strtotime( $m . '01' . $y));

to

echo $nono = date('m-t-Y', strtotime( $m . ' 01 ' . $y)); 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.