The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Trying To Grasp Time/Date Within TimeFrame
I'm working on a mod...and I'm stuck at a probably simple theory.
I have these expiration threads...and some of them are set to expire on certain days. What I essentially want to do is, if today is within 3 days of that expiration date, I want it to change a color. Now I'm not worried about the color change, but just the theory of how to write this code. PHP Code:
I'm stuck there, and I'm probably way off...but if a thread is going to expire within 3 days for example.. I want it to do something. Can anyone somewhat help me out here? The $thread['thread_expiry'] is already a defined variable and has the timestamp of the expiration |
#2
|
||||
|
||||
You need to have thread_expiry as a unix timestamp and then perform your date calculations on it.
|
#3
|
||||
|
||||
it is already a unix timestamp in the database
I just have no idea about the calculation part |
#4
|
||||
|
||||
If it already is a unix timestamp, then you can probably grab it out of the database like: SELECT ..... (UNIX_TIMESTAMP(NOW()) - thread.thread_expiry) as test, etc.... and then:
PHP Code:
|
#5
|
||||
|
||||
Lynne,
Well thats the confusion too is querying the database. Remember my other thread today where in forumdisplay_query hook I had: PHP Code:
THen outside of the query I wanted to write an IF conditional to say "if those threads that have expiry dates and have less than 3 days left before they expire", then turn them red. is that confusing? Do you need more info? argh |
#6
|
||||
|
||||
I was saying to use that in the query. So something like this:
PHP Code:
Then use what I wrote in the other plugin to see if that difference is within three weeks. |
#7
|
||||
|
||||
Ya I get no results...I think the query is off..I'll take a look and post results soon hopefully
I didnt know you could select something like what u put above...? I thought that had to be in the WHERE clause. Guess not huh? |
#8
|
||||
|
||||
You aren't getting any results? Or you aren't getting the value 'test'? If you are suddenly not getting results, then there is something typed wrong in that plugin. You might want to turn off that plugin, see if you get results, then turn it on and see if you get the same threads. Try spitting out the variable in your threadbit and see what number you get.
You might want to try just UNIX_TIMESTAMP() instead of UNIX_TIMESTAMP(NOW()) also. That's something I use on my tracker and I think I had to use NOW() there for one reason or another. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|