PHP从购买日期开始以印度格式计算到期日期

时间:2018-12-29 10:15:42

标签: php

如何将其转换为印度标准时间(天,月,年,日)显示不正确

$purchase_date = "12-29-2018 19:17:04";
$purchase_date_timestamp = strtotime($purchase_date);
$expiry = strtotime("+3 months", $purchase_date_timestamp);
echo date("Y-m-d h:i:s", $expiry);

1 个答案:

答案 0 :(得分:1)

$purchasedate='2018-12-01';
$no_months=3;

$expDate = date('d-m-Y', strtotime("+3 months", strtotime($purchasedate)));
$expDate = date('d-m-Y', strtotime("+".$no_months." months", strtotime($purchasedate))); 

更新

添加天数

$expDate = date('d-m-Y', strtotime("+3 days", strtotime($purchasedate)));
$expDate = date('d-m-Y', strtotime("+".$no_days." days", strtotime($purchasedate))); 

添加年份

$expDate = date('d-m-Y', strtotime("+3 years", strtotime($purchasedate)));

$expDate = date('d-m-Y', strtotime("+".$no_years." years", strtotime($purchasedate)));