【发布时间】:2020-10-08 13:18:54
【问题描述】:
如何在 smarty php 中创建验证,允许在指定日期后 30 天内显示该值?
在数组中:
Array (4)
0 => Array (13)
id => 6496
invoicenum => 6496
datecreated => "08/09/2020"
normalisedDateCreated => "2020-09-08"
我不知道什么是理想的领域,但我们可以使用 datecreated 或 normalisedDateCreated。
看起来像这样:
{if $invoice.datecreated ... } if it is more than 30 days from the current date it should display NO
YES
{else}
NO
{/if}
【问题讨论】:
-
您确定要在您的模板中执行此操作吗? stackoverflow.com/questions/27250242/… 对你有帮助吗?
-
嗯.. 不,因为他有两个特定的日期,我需要从当前日期开始间隔 30 天。
-
您可以将 DateTime 类与
diff()方法一起使用 -if ((new DateTime)->diff(new DateTime($invoice['normalisedDateCreated ']))->days > 30) -
@Qirel 不要使用 smarty php。
-
“不工作”是如此含糊,无法帮助解决问题。 确实 工作,它的原生 PHP。没有任何错误消息,真的不可能说出它为什么“不起作用”。也许应该是
$invoice[0]['normalisedDateCreated'],但这是基本的 PHP,我希望您至少尝试找出什么不起作用。
标签: php laravel smarty smarty3