<? if($rows_course_subject['begin_date']!=""){echo thaidate($rows_course_subject['begin_date']);}?> ถึง <? if($rows_course_subject['end_date']!=""){echo thaidate($rows_course_subject['end_date']);}?> <? //คำนวณจำนวณวัน //echo round(abs(strtotime("$rows_course_subject[begin_date]") - strtotime("$rows_course_subject[end_date]"))/60/60/24); ?> <strong>จำนวน</strong> : <? echo round(abs(strtotime("$rows_course_subject[begin_date]") - strtotime("$rows_course_subject[end_date]"))/60/60/24+1);?> <strong>วัน</strong></td> </tr> <tr> <td align="left"> </td> </tr> <tr> <td align="left" style="font-size:14px"><strong>เวลา</strong> : <? if($rows_course_subject['begin_time']!=""){echo $rows_course_subject['begin_time'];}?> ถึง <? if($rows_course_subject['end_time']!=""){echo $rows_course_subject['end_time'];}?> <?php // รูปแบบของเวลาที่ใช้คำนวณ แบบ // อยู่ในรูปแบบ 00:00:00 ถึง 23:59:59 function diff2time($time_a,$time_b){ $now_time1=strtotime(date("Y-m-d ".$time_a)); $now_time2=strtotime(date("Y-m-d ".$time_b)); $time_diff=abs($now_time2-$now_time1); $time_diff_h=floor($time_diff/3600); // จำนวนชั่วโมงที่ต่างกัน $time_diff_m=floor(($time_diff%3600)/60); // จำวนวนนาทีที่ต่างกัน $time_diff_s=($time_diff%3600)%60; // จำนวนวินาทีที่ต่างกัน //return $time_diff_h." ชั่วโมง ".$time_diff_m." นาที ".$time_diff_s." วินาที"; return ($time_diff_h-2); } // การใช้งาน //echo diff2time("17:42:51","16:37:56"); // ผลลัพธิ์ // 1 ชั่วโมง 4 นาที 55 วินาที ////////////////////////////////// $time_a = $rows_course_subject['begin_time']; $time_b = $rows_course_subject['end_time']; //$time_a="17:42:51"; //$time_b="16:37:56"; //echo diff2time($time_a,$time_b); // ผลลัพธิ์ // 1 ชั่วโมง 4 นาที 55 วินาที ?> <strong>จำนวน</strong> : <? echo diff2time($time_a,$time_b); ?> <strong>ชั่วโมง</strong></td>
$myday = round(abs(strtotime("$rows_course_subject[begin_date]") - strtotime("$rows_course_subject[end_date]"))/60/60/24+1); // วันที่ได้มา $myhour = diff2time($time_a,$time_b); // ชั่วโมงที่ได้มา $mysummary = ($myday * 24) + $myhour;
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง