PHP date_date_set()ฟังก์ชัน
ตัวอย่าง
ส่งกลับวัตถุ DateTime ใหม่ ตั้งค่าวันที่ใหม่ แล้วจัดรูปแบบวันที่:
<?php
$date=date_create();
date_date_set($date,2020,10,30);
echo date_format($date,"Y/m/d");
?>
ความหมายและการใช้งาน
ฟังก์ชัน date_date_set() กำหนดวันที่ใหม่
ไวยากรณ์
date_date_set(object, year, month, day)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
object | Required. Specifies a DateTime object returned by date_create() |
year | Required. Specifies the year of the date |
month | Required. Specifies the month of the date |
day | Required. Specifies the day of the date |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ส่งกลับวัตถุ DateTime ใหม่เมื่อสำเร็จ FALSE เมื่อล้มเหลว |
---|---|
รุ่น PHP: | 5.2+ |
บันทึกการเปลี่ยนแปลง PHP: | PHP 5.3: ค่าส่งคืนถูกเปลี่ยนจาก NULL เป็น DateTime (เมื่อสำเร็จ) |
❮ PHP วันที่/เวลาอ้างอิง