What are some common functions or methods for manipulating dates in PHP and MySQL?

When working with dates in PHP and MySQL, common functions or methods for manipulating dates include date(), strtotime(), and DATE_FORMAT(). These functions allow you to format dates, convert between different date formats, and perform date calculations.

// Get the current date in a specific format
$currentDate = date('Y-m-d');

// Convert a date string to a Unix timestamp
$timestamp = strtotime('2022-01-01');

// Format a date retrieved from a MySQL database
$query = "SELECT DATE_FORMAT(date_column, '%Y-%m-%d') AS formatted_date FROM table_name";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_assoc($result);
$formattedDate = $row['formatted_date'];