Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 10-07-2011, 03:07 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,683
SilverDragonTears is on a distinguished road
Default 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 = "";
}
__________________

Check out SilvaTales
Reply With Quote
  #2  
Old 10-07-2011, 03:23 PM
Inf3rnal's Avatar
Inf3rnal Inf3rnal is offline
Member
 
Join Date: Mar 2011
Location: Florida
Posts: 108
Gender: Male
Credits: 19,759
Inf3rnal is on a distinguished road
Default

Maybe try if then using the users registration date instead of 9/12/2011.
Reply With Quote
  #3  
Old 10-07-2011, 03:40 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 340,600
Hall of Famer is on a distinguished road
Default

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:
// First get the current date's timestamp using function time()
$badge time();
// Then convert the target dates to their corresponding timestamp form for comparison
$target mktime(0,0,0,9,11,2011);
if(
$badge >= $target){
// codes to execute if the date is after target date, such as Sep,12,2011
}
else{
// codes to execute if the date is before target date, such as Sep,12,2011

__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #4  
Old 10-08-2011, 02:57 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,683
SilverDragonTears is on a distinguished road
Default

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 =/
__________________

Check out SilvaTales
Reply With Quote
  #5  
Old 10-08-2011, 03:07 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 340,600
Hall of Famer is on a distinguished road
Default

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:
//Lets assume your date is in this format: 2011-09-11
$date "2011-09-11";
$datearray explode("-",$date);
$timestamp mktime(0,0,0,$datearray[1],$datearray[2],$datearray[0]); 
This way you will be able to get timestamp to work, hopefully you can see what I am doing here.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #6  
Old 10-08-2011, 03:33 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 82,683
SilverDragonTears is on a distinguished road
Default

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.
__________________

Check out SilvaTales
Reply With Quote
  #7  
Old 10-08-2011, 03:39 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 340,600
Hall of Famer is on a distinguished road
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:33 PM.

Currently Active Users: 9592 (0 members and 9592 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636