JS相当于PHP的“strtotime('-11 month')”

JS Equivalent of PHP's "strtotime('-11 month')"

本文关键字:month PHP 相当于 strtotime JS      更新时间:2023-09-26

有没有一种简单的方法可以获取11个月前的日期,在Javascript中甚至涉及JQuery。相当于使用 PHP 的strtotime('-11 month')。我知道您可以在 JS 的 Date 对象中轻松添加/减去天数,但月份稍微复杂一些,而不涉及每个月的所有天数。

也许这会帮助你。

http://phpjs.org/functions/strtotime/

PHPJS是一个了不起的网站,它的意义远不止于此。而且都是普通的JS,没有jQuery。

您可以使用 moment:

moment().subtract('months', 11).toDate()
我喜欢

php的方式,并将locutus(phpjs)组合成一个小的javascript类/函数作为替代方案:

http://tools.bitfertig.de/datebob.js/

datebob('-11 month')