Devils666 Posted April 4, 2010 Report Share Posted April 4, 2010 (edited) pats kods: if($ro['datums'] >= date("d-m-Y H:i:s", time()-24*60*60)){ echo '24 stundu limits'; } ar masiiviem sanāks tā: if('31-03-2010 22:57:54' >= '03-04-2010 17:40:30'){ echo '24 stundu limits'; } visu laiku if funkcija izpildas un saka 24 stundu limits, bet nu, kur man kļūda? kā butu pareizi? Edited April 4, 2010 by Devils666 Quote Link to comment Share on other sites More sharing options...
briedis Posted April 4, 2010 Report Share Posted April 4, 2010 Tev ir kaut kāda saprašana par datu tipiem? :)) ok, pēc tavām domām, kas ir lielāks "asfjkashdf238947rwejfhbsd" vai "dcse*(&9834923kdnvsdhfsdfsd"? Quote Link to comment Share on other sites More sharing options...
Devils666 Posted April 4, 2010 Author Report Share Posted April 4, 2010 nē nav :D tapēc prasu es vel tikai mācos php un ar lietam ko es neesmu saskaries nezinu Quote Link to comment Share on other sites More sharing options...
briedis Posted April 4, 2010 Report Share Posted April 4, 2010 Tad izlasi šos te: http://www.php.net/manual/en/language.operators.comparison.php http://www.php.net/manual/en/types.comparisons.php Tur arī atradīsi atbildi savai problēmai... Quote Link to comment Share on other sites More sharing options...
Devils666 Posted April 4, 2010 Author Report Share Posted April 4, 2010 kāpēc citiem visu saka priekša, bet man vienmer pasam viss jalasa? :D $laiks = date("d-m-Y", strtotime($datums)); $sodien = strtotime ('-0 day',strtotime(date("d-m-Y"))); if($laiks >= date('d-m-Y',$sodien)) { echo '24 stundu limits'; } tā butu labak? Quote Link to comment Share on other sites More sharing options...
briedis Posted April 4, 2010 Report Share Posted April 4, 2010 (edited) Man vnk negribas visu priekšā pateikt, vairāk iegūsi, ja pats sapratīsi, es tikai dodu norādes... Karoč, salīdzini unix timestampus, nevis tekstuālo cilvēkam saprotamo laiku. Dators tak nav nekāds gaišreģis, nesapratīs ko esi domājis ar saviem laikiem. Tik pat labi varētu prasīt, lai "lielaks" > "mazaks" būtu true, loģiskā nozīmē. Var provēt tekstuālo datumu pārvērst uz unix laiku ar to pašu strotitiem... if(strtotime(datums no db) > time() + 24stundas)){ echo ir pagājusi diennakts } Edited April 4, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
Devils666 Posted April 4, 2010 Author Report Share Posted April 4, 2010 (edited) $datums = '31-03-2010 22:57:54'; if(strtotime($datums) > time() - 24*60*60){ echo'ir pagājusi diennakts'; } biji domajis tā? man nez kapēc neiet... Edited April 4, 2010 by Devils666 Quote Link to comment Share on other sites More sharing options...
waplet Posted April 4, 2010 Report Share Posted April 4, 2010 sūdīgi :S Quote Link to comment Share on other sites More sharing options...
Devils666 Posted April 4, 2010 Author Report Share Posted April 4, 2010 bet nopietni, waplet tev iet? Quote Link to comment Share on other sites More sharing options...
waplet Posted April 4, 2010 Report Share Posted April 4, 2010 (edited) Tad, kad man vajag man iet. pie noderīgām funkcijām bija laika atskaite un tur notiek tāda paša salīdzināšana. iekš db man glabājās time(). nevis kaut kādi tur pārtaisīti par laiku .. Edited April 4, 2010 by waplet Quote Link to comment Share on other sites More sharing options...
Devils666 Posted April 4, 2010 Author Report Share Posted April 4, 2010 kads nevar pateikt, kas jadara, lai ietu? Quote Link to comment Share on other sites More sharing options...
waplet Posted April 4, 2010 Report Share Posted April 4, 2010 Briedis jau teica.. pārej uz UNIX laiku. un tad vari salīdzināt ar time()-24*60*60 Quote Link to comment Share on other sites More sharing options...
Devils666 Posted April 4, 2010 Author Report Share Posted April 4, 2010 hmm, ja es zinātu ka kaut ko tādu var izdarīt, tad senjau butu, bet es isti neko nesaprotu, manualus ari skatijos.. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted April 4, 2010 Report Share Posted April 4, 2010 Nevis "piecas stundas un divdesmit minūtes", bet "3600 * 5 + 60 * 20"... Kaut kā tā. :D Labojiet, ja kļūdos. :) Quote Link to comment Share on other sites More sharing options...
Devils666 Posted April 4, 2010 Author Report Share Posted April 4, 2010 (edited) ok, tas laiks anyway neko nemaina, tur ir kādu 4 dienu starpība, bet tāpat neiet tatad kāds nevar paradit aptuveni kā to varētu izdarīt? (man to funkciju ļoti vaig) Edited April 4, 2010 by Devils666 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.