Write a PHP script to add/subtract the number of days from a particular date
- برمجة بي اتش بي
- 2021-09-09
- mhanasmh00489829403
الأجوبة
<?php
$dt='2011-01-01';
echo 'Original date : '.$dt."\n";
$no_days = 40;
$bdate = strtotime("-".$no_days." days", strtotime($dt));
$adate = strtotime("+".$no_days." days", strtotime($dt));
echo 'Before 40 days : '.date("Y-m-d", $bdate)."\n";
echo 'After 40 days : '.date("Y-m-d", $adate)."\n";
?>
Sample Output:
Original date : 2011-01-01 Before 40 days : 2010-11-22 After 40 days : 2011-02-10
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال