php - 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);
解决方案
$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)));
推荐阅读
- python-3.x - PIL 调整大小过滤器与其整数表示之间的映射是什么?
- php - 在 Wordpress 结帐页面上收集电子邮件(适用于 Mailchimp 受众)
- ansible - 过滤已修改存储库的 webhook 有效负载
- sql - 如何编写具有多列的连接查询 - LINQ
- java - exec-maven-plugin:我可以在不先运行 toolchains:toolchain 目标的情况下运行 exec:exec 目标吗?
- javascript - 没有脚本的谷歌工作表中的多个依赖下拉列表
- angular - 打字稿全球字典
- python - 在 Pandas 中模糊搜索列
- python - 根据另一列的值计算熊猫列中的元素数
- python - 当我尝试按类查找元素时它不起作用(硒python)