Question

I need to print the Italian time from now to 30 days in this format 2013-03-11#11 Mar | Mon

I've found that the Date function don't return the italian translation so I'm using strftime.

but how can I add days to strftime?

setlocale(LC_ALL, 'it_IT');
for($i=0; $i<30; $i++){
    echo $date = date("Y-m-d", strtotime('now + '.$i.' days'));
    echo " # ";
    echo $date_string = strftime("%d %b | %a" );
    }
Was it helpful?

Solution 2

You can use this :

strftime("%d %b | %a",strtotime($date))

This will display the month and day.

OTHER TIPS

This code seems to solve your problem:

setlocale(LC_ALL, 'it_IT');
for($i=0; $i<30; $i++){
    echo $date = date("Y-m-d", strtotime('now + '.$i.' days'));
    echo " # ";
    echo $date_string = strftime( "%d %b | %a", strtotime('now + '.$i.' days') ) . "<br>";
}

The problem you were having is that, strftime, was using the default date, which is today. Looking at the documentation, http://php.net/manual/en/function.strftime.php, you can specify a timestamp for it to use instead, which is your future date (now +$i), as the second parameter.

Enjoy!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top