PHP date_interval_format()ฟังก์ชัน
ตัวอย่าง
คำนวณช่วงเวลาระหว่างวันที่สองวัน จากนั้นจัดรูปแบบช่วงเวลา:
<?php
$date1=date_create("2013-01-01");
$date2=date_create("2013-02-10");
$diff=date_diff($date1,$date2);
// %a outputs the total number of days
echo $diff->format("Total number of days: %a.");
?>
ความหมายและการใช้งาน
ฟังก์ชัน date_interval_format() เป็นนามแฝงของ DateInterval::format()
ฟังก์ชัน DateInterval::format() ใช้เพื่อจัดรูปแบบช่วงเวลา
ไวยากรณ์
DateInterval::format(format)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
format | Required. Specifies the format. The following characters can be used in the format parameter string:
Note: Each format character must be prefixed by a % sign! |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ส่งกลับช่วงเวลาที่จัดรูปแบบ |
---|---|
รุ่น PHP: | 5.3+ |
บันทึกการเปลี่ยนแปลง PHP: | PHP 7.1: เพิ่มพารามิเตอร์Fและf |
❮ PHP วันที่/เวลาอ้างอิง