date - PHP - Time based math -
How is this correct? There are so many questions on the stack that what I am trying to do; However all the solutions are to edit the MySQL query, and I need to do this from within PHP.
I read on another question about strotomium ('- 30 days') method and tried to do it, but I can not find any results. Here's what I'm trying to do:
$ current_date = date_create (); $ Current_date- & gt; Format ('U'); ... mysql code ... $ transaction_date = date_create ($ affiliate ['date']); $ Transaction_date- & gt; Format ('U'); (TRANSACTION_DATE & gt;; ($ CURRENT_DATE - strtotime ('- 30 days'))) {} else if (($ TRANSACTION_DATE & lt; ($ CURRENT_DATE) - (strtotime ('- 30 days')))) & Amp; amp; ($ TRANSACTION_DATE & gt; (($ CURRENT_DATE) - (strtotime ('- 60 days'))))} {}
Effectively, I Trying to sort all the data in the database based on a date, and if the database entry was posted within the past 30 days, then I want to do a function, so I have to check whether the database entry 30 Days old, lake Do not older than 60 days and much more action.
This era math is really weird, you want to think that the era of present time, the era of data entry, and the era of 30 and 60 days was going to be quite good before I wanted to Maybe, but if it does not work for some reason, then everything is going to be at least 30 days old, even though I have come back in the prescribed form in the previous year's database.
There is no need to change to Unix T, you can already compare Date time
items:
$ CURRENT_DATE = data_create (); $ Before_30_day_date = date_create ('- 30 days'); $ Before_60_day_date = date_create ('- 60 days'); $ Transaction_date = date_create ($ affiliate ['date']); If {# transaction date is between -60 days and ($ TRANSACTION_DATE & gt; $ before_30_day_date) elseif (; $ before_30_day_date & amp; $ $ TRANSACTION_DATE & gt; before_60_day_date $ TRANSACTION_DATE & lt) {# Transaction date is between 30 days and future} -30 days}
Comments
Post a Comment