ใช่ เปลี่ยนรูปแบบวันที่ใน PHP โดยใช้ date() พร้อมกับ strtotime() สมมติว่าต่อไปนี้คือวันที่ของเรา -
$dateValue = "2020-09-19";
เปลี่ยนรูปแบบวันที่โดยใช้เมธอด strtotime() -
$modifiedDate= date("d-m-Y", strtotime($dateValue)); ตัวอย่าง
<!DOCTYPE html>
<html>
<body>
<?php
$dateValue = "2020-09-19";
echo "The original date format is=",$dateValue,"<br>";
$modifiedDate= date("d-m-Y", strtotime($dateValue));
echo "The changed date format is= ".$modifiedDate;
?>
</body>
</html> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้
The original date format is=2020-09-19 The changed date format is= 19-09-2020