What PHP function can be used to convert a date from the format YYYY-MM-DD to DD.MM.YYYY?
To convert a date from the format YYYY-MM-DD to DD.MM.YYYY in PHP, you can use the `date()` function along with `strtotime()` to parse the original date string and format it accordingly. By using `date('d.m.Y', strtotime($original_date))`, you can easily convert the date format.
$original_date = '2022-01-15';
$new_date = date('d.m.Y', strtotime($original_date));
echo $new_date; // Output: 15.01.2022
Keywords
Related Questions
- How can the PHP code be optimized to improve performance when retrieving and displaying font options from a database?
- What best practices should be followed when handling session variables in PHP to ensure reliable data transfer between templates?
- How can PHP be used to read only JPG files from a specified directory?