一个月差距计算 [英] One month gap calculation

查看:132
本文介绍了一个月差距计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从数据库中找到应该在30天之后的日期。

I am trying to find the date from the database which should be exactly 30 days from now.

我想从数据库中检索日期,这个日期是 DateTime 格式。使用 strtotime()将其更改为时间戳。将其提供给 date()并检索 m i 然后做本地计算,以确定它是否不太恰恰三十天。

I want to retrieve the date from the database which is DateTime format. change this to timestamp with strtotime(). feed this to date() and retrieve the mand i and then do local calculation to find out if its less exactly thirty days.

我想知道是否有任何直接和简单的过程来做到这一点。

I want to know if there is any straight forward and easy procedure to do this.

推荐答案

尝试这样:

$date_formatted = date('Y-m-d H:i:s', strtotime($val->time));

要检索 m i 或两者都尝试这样:

To retrieve the m or i or both, try this :

$v = date('Y-m-d H:i:s'); //test it with now.
$date_formatted = date('m i', strtotime($v));

要从数据库中查找30天之内的日期,您可以尝试以下方式:

For find date from database that exactly 30 days from now you can try this:

$date_formatted = date('Y-m-d H:i:s', strtotime(' +30 day'));

这篇关于一个月差距计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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