如何从今天算起减去4个月? [英] How to subtract 4 months from today's date?

查看:79
本文介绍了如何从今天算起减去4个月?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以"Ymd"格式声明两个日期:$toDate$fromDate.

I need to declare two dates in "Ymd" format: $toDate and $fromDate.

$toDate代表今天的日期,$fromDate必须比今天早4个月.

$toDate represents today's date and $fromDate needs to be 4 months earlier than today.

$toDate = Date('Ymd');
$fromDate = ?

如何创建$fromDate?

推荐答案

使用 strtotime :

Use the magic of strtotime:

$fromDate = date("Ymd", strtotime("-4 months"));

这篇关于如何从今天算起减去4个月?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆