Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts

    See if member is new within last month

    I had to write code that would take the date the user was created (from a date column in MySQL) and see if he was within a month of having joined, and therefore new to my site. If he is new, it will make his type "new," to distinguish him from long-time members. Here's the code for it.

    PHP Code:
    // Get the CreatedDate from the MySQL database...do a query on that field for whatever 
    // record you want.  For simplicity, I've just gotten today's date in the normal format.

    $created_year date('Y');
    $created_month date('m');
    $created_day date('d');

    // Add 1 month to the created month.

    $time_as_new strtotime("+1 month"mktime(0,0,0,$created_month,$created_day,$created_year));

    // If the time allocated (1 month) for a user to be new is more than the current time, 
    // make the member's type "new."

    if ($time_as_new >= time()) {
        
    $member_type_new 'New Member';

    It took me forever to figure this out, so I hope that helps someone! If you notice any errors or improvements, please critique away.

  • #2
    Regular Coder nexosis's Avatar
    Join Date
    Dec 2006
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think many forums support this, BTW, nothing to comment at all, nice.
    used phpdate?

    progress: HTML: 100% > CSS: 90% > Javascript: 55% > Php:10%
    Want an avatar like mine? it's free! just pm me.

  • #3
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    Nope. What is phpdate?

  • #4
    Regular Coder nexosis's Avatar
    Join Date
    Dec 2006
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what is phpdate?
    http://php.net/date

    progress: HTML: 100% > CSS: 90% > Javascript: 55% > Php:10%
    Want an avatar like mine? it's free! just pm me.

  • #5
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    I'm sure there's a way you can get all that straight from a db query, but I can't remember how it's done lol.

    It'll be in here somewhere
    http://dev.mysql.com/doc/refman/5.0/...functions.html
    Last edited by Nightfire; 03-22-2007 at 02:06 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •