[eluser]Unknown[/eluser]
Thank you, it was almost exactly what I needed.
I had used a similar approach ( little bit lammer )
If possible could you tell me where did you get the acceptables formats to use into mdate()?
something such as
%M = part of months name
%d = number of current day
and so on?
Follows the modification I did to the mdate()
Code:
function mdate($datestr = '', $time = '')
{
if ($datestr == '')
return '';
if ($time == '')
$time = now();
if ($datestr == 'F'){
switch (date($datestr, $time)){
case 'January' :
return 'janeiro';
break;
case 'February' :
return 'fevereiro';
break;
case 'March' :
return 'março';
break;
case 'April' :
return 'abril';
break;
case 'May' :
return 'maio';
break;
case 'June' :
return 'junho';
break;
case 'July' :
return 'julho';
break;
case 'August' :
return 'agosto';
break;
case 'September' :
return 'setembro';
break;
case 'October' :
return 'outubro';
break;
case 'November' :
return 'novembro';
break;
case 'December' :
return 'dezembro';
break;
}
}
$datestr = str_replace('%\\', '', preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr));
return date($datestr, $time);
}
And doing like this I'm going to get the next month if you're accessing before the 15th and the next next month if its after the 15th.
Code:
function periodo_mes($tipo = ''){
(mdate('%d')>15) ? $m=2 : $m=1;
if ($tipo == 'extenso'){
$mes = mdate('F', mktime(0, 0, 0, mdate('%m')+$m, mdate('%d'), mdate('%Y')));
return $mes;
} else {
return mdate('%m')+$m;
}
}
Portuguese notes
extenso = full name
mes = month
periodo = period (not the red one)