Log 2573

$field = “השדה הזה נמצא בקבוצה חוזרת, אני רוצה שתחזיר לי את התאריך הכיח קרוב מבין כל התאריכים הנמצאים בשדה זה”;

$dates = explode(” “, $field);
$currentDate = date(“d/m/Y”);
$closestDate = “”;

foreach ($dates as $date) {
if (empty($closestDate)) {
$closestDate = $date;
} else {
$currentDiff = strtotime($date) – strtotime($currentDate);
$closestDiff = strtotime($closestDate) – strtotime($currentDate);

if (abs($currentDiff) < abs($closestDiff)) {
$closestDate = $date;
}
}
}

return $closestDate;

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
  • Attributes
  • Custom attributes
  • Custom fields
Click outside to hide the comparison bar
Compare