Hàm checkdate () trong PHP
Thí dụ
Kiểm tra xem một số ngày có phải là ngày Gregorian hợp lệ hay không:
<?php
var_dump(checkdate(12,31,-400));
echo "<br>";
var_dump(checkdate(2,29,2003));
echo "<br>";
var_dump(checkdate(2,29,2004));
?>
Định nghĩa và Cách sử dụng
Hàm checkdate () được sử dụng để xác thực một ngày Gregorian.
Cú pháp
checkdate(month, day, year)
Giá trị tham số
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 |
Chi tiết kỹ thuật
Giá trị trả lại: | ĐÚNG nếu ngày đó hợp lệ. FALSE nếu không |
---|---|
Phiên bản PHP: | 4.0+ |
❮ Tham chiếu ngày / giờ PHP