Is a function available in PHP, which can print random month?
Like mt_rand(); to print random number.
If NO, what will easy method to print random month?
I am using below code:
$randmo = mt_rand(1,12);
if($randmo == 1)
{
$randmonth = "Jan";
}
elseif($randmo == 2)
{
$randmonth = "Feb";
}
elseif($randmo == 3)
{
$randmonth = "Mar";
}
elseif($randmo == 4)
{
$randmonth = "Apr";
}
elseif($randmo == 5)
{
$randmonth = "May";
}
elseif($randmo == 6)
{
$randmonth = "Jun";
}
elseif($randmo == 7)
{
$randmonth = "Jul";
}
elseif($randmo == 8)
{
$randmonth = "Aug";
}
elseif($randmo == 9)
{
$randmonth = "Sep";
}
elseif($randmo == 10)
{
$randmonth = "Oct";
}
elseif($randmo == 11)
{
$randmonth = "Nov";
}
else
{
$randmonth = "Dec";
}
echo $randmonth;
First i am storing a rand number from 1 to 12 in $randmo variable. And printing using if else. I am looking for better script.