首页 > 解决方案 > 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);

标签: php

解决方案


$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))); 

推荐阅读