nunoturbina Posted August 19, 2012 at 01:14 AM Report Share #472806 Posted August 19, 2012 at 01:14 AM Boas, Necessito de ajuda com um problema. Eu tenho uma variavel que me diz que semana é, e que quando seja domingo passe para a próxima semana, e que ao fim de 4 semanas volte para a semana 1. Eu tentei como está em baixo, e a variável semana nunca altera. $semana=1; $date = date("Y/m/d"); $date = strtotime($date); $date = date("l", $date); $date = strtolower($date); if($date == "saturday") $semana++; if($semana > 4) $semana = 1; Link to comment Share on other sites More sharing options...
yoda Posted August 19, 2012 at 01:18 AM Report Share #472808 Posted August 19, 2012 at 01:18 AM Como assim, que semana é? Se é a 1, 2, 3ª semana do mês? before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to comment Share on other sites More sharing options...
pikax Posted August 19, 2012 at 01:20 AM Report Share #472809 Posted August 19, 2012 at 01:20 AM (edited) saturday nao e' sabado? nao seria Sunday? $semana=1; $date = date("Y/m/d"); $date = strtotime($date); $date = date("l", $date); $date = strtolower($date); if($date == "saturday") $semana++; if($semana > 4) $semana = 1; porque que estas sempre a atribuir valores ao $date? O valor nunca muda, porque inicializas a variavel semana a 1, se for sabado entao vai incrementar a semana, que ira' dar 2. PS: nao percebi muito bem o que queres exactamente Edited August 19, 2012 at 01:21 AM by pikax Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast." Link to comment Share on other sites More sharing options...
nunoturbina Posted August 19, 2012 at 01:26 AM Author Report Share #472811 Posted August 19, 2012 at 01:26 AM Já funciona! Realmente, a cena do "saturday" foi muito ao lado... verifiquei que tinha também varias variaveis com o mesmo note "date" tratei de alterar e ficou tudo bom. Obrigado! Link to comment Share on other sites More sharing options...
yoda Posted August 19, 2012 at 02:04 AM Report Share #472814 Posted August 19, 2012 at 02:04 AM date_default_timezone_set('Europe/Lisbon'); $week = 1; $day = (int) date('N'); if ($day == 7) $week++; if ($week > 4) $week = 1; before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to comment Share on other sites More sharing options...
RootShell Posted August 29, 2012 at 10:03 AM Report Share #473943 Posted August 29, 2012 at 10:03 AM (edited) A solução está aqui: http://stackoverflow.com/a/10943258 Edited August 29, 2012 at 10:24 AM by RootShell Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now