#1
|
||||
|
||||
PHP ?
I tried to make it so that if a member has joined after Sep 11 the badge doesn't show up but if they joined before or on Sep 11 it shows. But it's showing up for some people who registered after. Here is my code
Code:
if($badge <= "Sep 11, 2011"){ $badge = " <img src='/images/us.png' title='9/11 Badge'>"; }else if($badge <= "2011-09-11"){ $badge = " <img src='/images/us.png' title='9/11 Badge'>"; }else if($badge >= "Sep 12, 2011"){ $badge = ""; }else if($badge >= "2011-09-12"){ $badge = ""; } |
#2
|
||||
|
||||
Maybe try if then using the users registration date instead of 9/12/2011.
|
#3
|
||||
|
||||
Well a couple of comments to make:
1. You have defined your dates as strings, you cannot compare if a string is greater or smaller than another string, they only work for numbers(integers or floating numbers). 2. In order to compare dates, you will need to convert them into their corresponding timestamp forms. A timestamp defines how many seconds have elapsed since Jan, 1, 1970, its an integer type number. 3. To convert the current date into its corresponding timestamp form, use the function time(). To convert an arbitrary date to timestamp, the function mktime() must be called. The following sample script is an example of how to compare dates: PHP Code:
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
#4
|
||||
|
||||
i tried it but it converted the membersince date into a weird format and didn't work anyways. i just took it off for now and will try to think of a different way to give my members badges based on dates =/
|
#5
|
||||
|
||||
I am assuming it was because your members registration date was in this format: Year - Month - Day? If so, you will need to play a small trick in it before sending to the mktime() function:
PHP Code:
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
#6
|
||||
|
||||
No it's (M, d, y) and I have no idea what you're doing, lol! I just think I need a better way of giving users badges. What I WANT to do is if they log on the day that the badges are given out, then they receive that badge.
|
#7
|
||||
|
||||
I see, I will take a look into it later. Anyway manipulating PHP date functions is not an easy job, its strongly recommended that you are at least an intermediate-leveled PHP programmer before playing around with them.
__________________
Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site. |
|
|
What's New? |
What's Hot? |
What's Popular? |