xxxxxxxxxx
date("Y-m-d H:i:s", strtotime($_POST['timestamp']));
xxxxxxxxxx
<?php
// Assuming you have established a MySQL database connection
// Query to retrieve the current date and time from MySQL
$query = "SELECT NOW() AS current_datetime";
$result = mysqli_query($connection, $query);
// Check if the query was successful
if ($result) {
// Fetch the result row
$row = mysqli_fetch_assoc($result);
// Retrieve the current datetime
$datetime = $row['current_datetime'];
// Format the datetime as desired (e.g., "Y-m-d H:i:s")
$formattedDatetime = date('Y-m-d H:i:s', strtotime($datetime));
// Output the formatted datetime
echo "Formatted Datetime: " . $formattedDatetime;
} else {
// Handle query error
echo "An error occurred.";
}
// Remember to close the database connection when you're done
mysqli_close($connection);
?>