PHP checkdate()ฟังก์ชั่น
ตัวอย่าง
ตรวจสอบว่าวันที่หลายวันเป็นวันเกรกอเรียนที่ถูกต้องหรือไม่:
<?php
var_dump(checkdate(12,31,-400));
echo "<br>";
var_dump(checkdate(2,29,2003));
echo "<br>";
var_dump(checkdate(2,29,2004));
?>
ความหมายและการใช้งาน
ฟังก์ชัน checkdate() ใช้สำหรับตรวจสอบวันที่แบบคริสต์ศักราช
ไวยากรณ์
checkdate(month, day, year)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
month | Required. Specifies the month as a number between 1 and 12 |
day | Required. Specifies the day as a number between 1 and 31 |
year | Required. Specifies the year as a number between 1 and 32767 |
รายละเอียดทางเทคนิค
คืนมูลค่า: | TRUE หากวันที่ถูกต้อง เท็จ มิฉะนั้น |
---|---|
รุ่น PHP: | 4.0+ |
❮ PHP วันที่/เวลาอ้างอิง