Jump to content
php.lv forumi

date Y.m > W


edi

Recommended Posts

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 by edi
Link to comment
Share on other sites

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 by edi
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...