Reputation: 148
I have this piece of code:
<?php
setlocale(LC_ALL,"es_ES");
$contador = 1;
$diaActual = time();
while ($contador <= 7) {
echo date("D j-n-Y", $diaActual)."<br><br>";
$contador++;
$diaActual = strtotime("+1 day", $diaActual);
}
?>
Result:
Tue 13-5-2014
Wed 14-5-2014
Thu 15-5-2014
Fri 16-5-2014
Sat 17-5-2014
Sun 18-5-2014
Mon 19-5-2014
Why isn't working?
Upvotes: 1
Views: 1283
Reputation: 23777
From the manual about date()
To format dates in other languages, you should use the setlocale() and strftime() functions instead of date().
So use strftime()
:
print strftime("%a %d-%m-%Y");
To sum up always one day, just use a timestamp like:
for ($time = time(), $contador = 1;
$contador <= 7;
$contador++, $time = strtotime('+1 day', $time)) {
print strftime("%a %d-%m-%Y", $time)."<br />\n";
}
Upvotes: 2