/    Sign up×
Community /Pin to ProfileBookmark

Year´s month´s names

<?
function generatecalendar() {
$ano = date(‘Y’);
print ($ano-1);
echo ” | | “;
for($i;$i<=12;$i++){
echo $i.” | “;
}
echo ” | | “;
print ($ano+1);
}

generatecalendar();

?>
Hi

I would like to generate a mini calendar displaying a year before the actual year number the 12 months from the year and the year number after the actual year. The function above generate the months number.

i would like to generate the three first letters from the months but in portuguese ! how can i do this ?

Thank´s in advance

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@SpectreReturnsSep 05.2005 — Make an array containing the first three letters of each month, then use your month number to access the correct one.
Copy linkTweet thisAlerts:
@cyber1Sep 05.2005 — Or you could just use the follwing:

-Bill
[code=php]<?php
$years_back=1;
$years_togo=2;
$duaration = ($years_togo*12);
for($i=1;$i<$duaration;$i++){
print date('M d,Y',mktime(0, 0, 0, $i, 1, date('Y')-$years_back))."|n";
}
[/code]
Copy linkTweet thisAlerts:
@bokehSep 06.2005 — I've used your code here but just made a minor change:[code=php]<?php

function generatecalendar()
{
$ano = date('Y');
print ($ano-1);
echo " | | ";

$meses = array('1' => 'Ene', 'Feb', 'Mar', 'Abr', 'May',
'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic');

for($i = 1;$i<=12;$i++){
echo $meses[$i]." | ";
}
echo " | | ";
print ($ano+1);
}

generatecalendar();

?>[/code]
Copy linkTweet thisAlerts:
@amrigoauthorSep 06.2005 — thank´s i have used a switch i will try the array.
×

Success!

Help @amrigo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...