|
|
|
ช่วยดู code นี้ให้หน่อยได้ไหมค่ะว่า ตรงไหนที่มันเป็นการรับค่าให้เป็น mm/dd/yyyy |
|
|
|
|
|
|
|
Code (PHP)
<head><meta http-equiv=Content-Type content="text/html; charset=utf-8"> </head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?php
// Get values from query string
$day = $_GET["day"];
$month = $_GET["month"];
$year = $_GET["year"];
$sel = $_GET["sel"];
$what = $_GET["what"];
$field = $_GET["field"];
$form = $_GET["form"];
if($day == "") $day = date("j");
if($month == "") $month = date("m");
if($year == "") $year = date("Y");
$currentTimeStamp = strtotime("$year-$month-$day");
$numDays = date("t", $currentTimeStamp);
$monthName = date("F", $currentTimeStamp);
$counter = 0;
/*$numEventsThisMonth = 0;
$hasEvent = false;
$todaysEvents = "";*/
?>
<html>
<head>
<title>ปฏิทิน</title>
<link rel="stylesheet" type="text/css" href="calendar.css">
<script language="javascript">
function goLastMonth(month,year,form,field)
{
// If the month is January, decrement the year.
if(month == 1)
{
--year;
month = 13;
}
document.location.href = 'calendar.php?month='+(month-1)+'&year='+year+'&form='+form+'&field='+field;
}
function goNextMonth(month,year,form,field)
{
// If the month is December, increment the year.
if(month == 12)
{
++year;
month = 0;
}
document.location.href = 'calendar.php?month='+(month+1)+'&year='+year+'&form='+form+'&field='+field;
}
function sendToForm(val,field,form)
{
// Send back the date value to the form caller.
eval("opener.document." + form + "." + field + ".value='" + val + "'");
window.close();
}
</script>
</head>
<body style="margin:0px 0px 0px 0px" class="body">
<table width='175' border='0' cellspacing='0' cellpadding='0' class="body">
<tr>
<td width='25' colspan='1'>
<input type='button' class='button' value=' < ' onClick='<?php echo "goLastMonth($month,$year,\"$form\",\"$field\")"; ?>'>
</td>
<td width='125' align="center" colspan='5'>
<span class='title'><?php echo $monthName . " " . $year; ?></span><br>
</td>
<td width='25' colspan='1' align='right'>
<input type='button' class='button' value=' > ' onClick='<?php echo "goNextMonth($month,$year,\"$form\",\"$field\")"; ?>'>
</td>
</tr>
<tr>
<td class='head' align="center" width='25'>S</td>
<td class='head' align="center" width='25'>M</td>
<td class='head' align="center" width='25'>T</td>
<td class='head' align="center" width='25'>W</td>
<td class='head' align="center" width='25'>T</td>
<td class='head' align="center" width='25'>F</td>
<td class='head' align="center" width='25'>S</td>
</tr>
<tr>
<?php
for($i = 1; $i < $numDays+1; $i++, $counter++)
{
$timeStamp = strtotime("$year-$month-$i");
if($i == 1)
{
// Workout when the first day of the month is
$firstDay = date("w", $timeStamp);
for($j = 0; $j < $firstDay; $j++, $counter++)
echo "<td> </td>";
}
if($counter % 7 == 0)
echo "</tr><tr>";
if(date("w", $timeStamp) == 0)
$class = "class='weekend'";
else
if($i == date("d") && $month == date("m") && $year == date("Y"))
$class = "class='today'";
else
$class = "class='normal'";
echo "<td class='tr' bgcolor='#ffffff' align='center' width='25'><a class='buttonbar' href='#' onclick=\"sendToForm('".sprintf("%02d/%02d/%04d", $i, $month, $year)."','$field','$form');\"><font $class>$i</font></a></td>";
}
?>
</tr>
</table>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-05-11 09:37:27 |
By :
juneneka |
View :
876 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
งงคำถามครับ
|
|
|
|
|
Date :
2012-05-11 12:45:10 |
By :
tannabor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อันนี้ครับ
onclick=\"sendToForm('".sprintf("%02d/%02d/%04d", $i, $month, $year)."','$field','$form');\"
ถ้าจะให้เป็น mm/dd/YYY ให้เปลี่ยนเป็น
onclick=\"sendToForm('".sprintf("%02d/%02d/%04d", $month, $i, $year)."','$field','$form');\"
|
|
|
|
|
Date :
2012-05-11 21:02:03 |
By :
tongjaab |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อันนี้จูนลองเปลี่ยนแล้วค่ะ ค่ามันเปลี่ยนจริง แต่มันยังอยู่ในรูปแบบ mm/dd/yyyy ทั้งๆที่ ค่าเปลี่ยนเปน dd/mm/yyyy แล้ว งงจริงๆ
|
|
|
|
|
Date :
2012-05-12 14:54:02 |
By :
juneneka |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองคลิ๊กขวาแล้ว view source ได้ผลลัพธ์แบบนี้ครับ
Code (PHP)
<tr>
<td class='tr' bgcolor='#ffffff' align='center' width='25'><a class='buttonbar' href='#' onclick="sendToForm('01/05/2012','','');"><font class='normal'>1</font></a></td>
<td class='tr' bgcolor='#ffffff' align='center' width='25'><a class='buttonbar' href='#' onclick="sendToForm('02/05/2012','','');"><font class='normal'>2</font></a></td>
<td class='tr' bgcolor='#ffffff' align='center' width='25'><a class='buttonbar' href='#' onclick="sendToForm('03/05/2012','','');"><font class='normal'>3</font></a></td>
<td class='tr' bgcolor='#ffffff' align='center' width='25'><a class='buttonbar' href='#' onclick="sendToForm('04/05/2012','','');"><font class='normal'>4</font></a></td>
<td class='tr' bgcolor='#ffffff' align='center' width='25'><a class='buttonbar' href='#' onclick="sendToForm('05/05/2012','','');"><font class='normal'>5</font></a></td>
</tr>
<tr>
<td class='tr' bgcolor='#ffffff' align='center' width='25'><a class='buttonbar' href='#' onclick="sendToForm('06/05/2012','','');"><font class='weekend'>6</font></a></td>
<td class='tr' bgcolor='#ffffff' align='center' width='25'><a class='buttonbar' href='#' onclick="sendToForm('07/05/2012','','');"><font class='normal'>7</font></a></td>
<td class='tr' bgcolor='#ffffff' align='center' width='25'><a class='buttonbar' href='#' onclick="sendToForm('08/05/2012','','');"><font class='normal'>8</font></a></td>
|
|
|
|
|
Date :
2012-05-12 16:32:05 |
By :
sakuraei |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ความต้องการ จะทำอะไรครับ
ถ้าต้องการใช้ปฏิทิน แนะนำใช้ jquery datepicker ง่ายกว่าครับ
http://jqueryui.com/demos/datepicker/
หากไม่ใช่ก็ขออภัยครับ
|
ประวัติการแก้ไข 2012-05-12 16:47:34
|
|
|
|
Date :
2012-05-12 16:40:38 |
By :
boodemon |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|