Pergunta

I'm trying to get a date from a html, and i use mktime to convert it to a day like: Monday

$dayisarr=date( "l", mktime(0,0,0, $duedt[1], $duedt[0],$duedt[2] ));  

when i print it , it returns me a wrong day...like Friday which is wrong..
i tried to change the l to r, which prints the whole date and it printed me the wrong month and year.. ive searched for a long long time in the internet and i didnt find nothing.

Foi útil?

Solução 2

You can use

$dayisarr=date( "l", strtotime($duedt[2] . '-' . $duedt[1] . '-' . $duedt[0]));

Outras dicas

Why use mktime? DateTime is far simpler.

$duedt = array(8, 14, 2013);
$dayisar = (new \DateTime())->setDate($duedt[2], $duedt[0], $duedt[1])->format('l');
var_dump($dayisar);

Output:-

string 'Wednesday' (length=9)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top