edi Posted December 17, 2009 Report Share Posted December 17, 2009 ja lietotājs ir izvēlējies gadu,mēnesi un dienu, kā var dabūt izvēlētā datuma nedēļu? Quote Link to comment Share on other sites More sharing options...
bubu Posted December 17, 2009 Report Share Posted December 17, 2009 Apskati date funkcijas dokumentācijā "W" formātu. Quote Link to comment Share on other sites More sharing options...
edi Posted December 17, 2009 Author Report Share Posted December 17, 2009 (edited) Apskati date funkcijas dokumentācijā "W" formātu. tur loti plasi tas ir aprakstits W ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) <? function GetValidDate($month=1, $day=1, $year=1970) { $day = min(31, max(1, intval($day))); $month = min(12, max(1, intval($month))); $year = max(1970, intval($year)); switch($month) { case 2 : if($day > 28) $day = ($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0)) ? 29 : 28; break; //** only maximum of thirty days in these months. case 4 : //** APRIL case 6 : //** JUNE case 9 : //** SEPTEMBER case 11 : //** NOVEMBER $day = min(30, $day); break; } return mktime(0, 0, 0, $month, $day, $year); } ?> <html> <body> <form method="post"> <font face="verdana" size="2"> <i>Izvelieties.. datumu:</i><br> <select name="month"> <option value="1">Janvāris</option> <option value="2">Februāris</option> <option value="3">Marts</option> <option value="4">Aprīlis</option> <option value="5">Maijs</option> <option value="6">Junijs</option> <option value="7">Julijs</option> <option value="8">Augusts</option> <option value="9">Septembris</option> <option value="10">Oktobris</option> <option value="11">Novembris</option> <option value="12">Decembris</option> </select> <select name="day"> <? for($index=1; $index <= 31; $index++) echo "<option value='$index'>$index</option>"; ?> </select> <select name="year"> <? for($index=2009; $index <= 2025; $index++) echo "<option value='$index'>$index</option>"; ?> </select> <input type="submit" name="dodisplay" Value=" Validate "><br><br> <? if(isset($_REQUEST["dodisplay"])) { echo "datums",date("F d, Y W", GetValidDate($_REQUEST["month"],$_REQUEST["day"],$_REQUEST["year"],$_REQUEST["week"])), "(", "month=", $_REQUEST["month"], " day=", $_REQUEST["day"], " year=", $_REQUEST["year"], " week=", $_REQUEST["week"], ")"; } ?> </font> </form> </body> </html> nedelu izvada pareizo, bet kad izvada ar $_REQUEST["week"] nekas nesanak :) .. zinu kapec neizvada, bet tas neko nedod ) vajag beigās dabūt tā, lai ar varētu izvēlēto datumu izvadīt šādu, gads-menesis-diena .. un te kaut kur nedela :) un katru datumu atsevišķi Edited December 17, 2009 by edi Quote Link to comment Share on other sites More sharing options...
Val Posted December 17, 2009 Report Share Posted December 17, 2009 (edited) if(isset($_REQUEST["dodisplay"])) { echo date("\d\a\\t\u\m\s\: F d, Y \| \\n\e\d\e\l\j\a\: W", GetValidDate($_REQUEST["month"],$_REQUEST["day"],$_REQUEST["year"])); } Edited December 17, 2009 by Val Quote Link to comment Share on other sites More sharing options...
edi Posted December 17, 2009 Author Report Share Posted December 17, 2009 if(isset($_REQUEST["dodisplay"])) { echo date("\d\a\\t\u\m\s\: F d, Y \| \\n\e\d\e\l\j\a\: W", GetValidDate($_REQUEST["month"],$_REQUEST["day"],$_REQUEST["year"])); } un kā es tev nedelu dabūšu mysql querty iekšā? ) Quote Link to comment Share on other sites More sharing options...
Val Posted December 17, 2009 Report Share Posted December 17, 2009 qwerty vari uz klaviatūras uzsist. man nekur to nedēļu nevajag dabūt iekšā. echo date("W", GetValidDate($_REQUEST["month"],$_REQUEST["day"],$_REQUEST["year"])); ar datumu līdzīgi. Quote Link to comment Share on other sites More sharing options...
edi Posted December 17, 2009 Author Report Share Posted December 17, 2009 (edited) qwerty vari uz klaviatūras uzsist. man nekur to nedēļu nevajag dabūt iekšā. echo date("W", GetValidDate($_REQUEST["month"],$_REQUEST["day"],$_REQUEST["year"])); ar datumu līdzīgi. $query = mysql_query ( "SELECT * FROM `user_atsk` WHERE `date`='".gads-menesis-diena."' AND `week`='".$week."'") or die ( mysql_error ()); vispar butu baigi labi ja varetu, kur `date` salīdzināt ierakstus kuriem visiem ir tads gads :) db datums glabajas 2009-12-17 $query = mysql_query ( "SELECT * FROM `user_atsk` WHERE `date`='".gads.."' AND `week`='".$week."'") or die ( mysql_error ()); Edited December 17, 2009 by edi 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.