Log 2661
28/01/2024 2024-01-28 15:18// Set the values for placeholders
$creationDate = “10/12/2022”; // Example value, replace with actual creation date
$orderDate = “”; // Example value, replace with actual order date
$currentDate = “15/12/2022”; // Example value, replace with actual current date
// Check if the order date is empty
if (empty($orderDate)) {
$daysPassed = calculateDaysPassed($creationDate, $currentDate);
} else {
$daysPassed = calculateDaysPassed($orderDate, $currentDate);
}
return “Number of days passed: ” . $daysPassed;
// Function to calculate the number of days passed between two dates in day/month/year format
function calculateDaysPassed($startDate, $endDate)
{
// Convert dates to timestamps
$startTimestamp = strtotime(str_replace(‘/’, ‘-‘, $startDate));
$endTimestamp = strtotime(str_replace(‘/’, ‘-‘, $endDate));
// Calculate number of seconds between two dates
$secondsDiff = abs($endTimestamp – $startTimestamp);
// Calculate number of days from seconds difference
return floor($secondsDiff / (60 * 60 * 24));
}