Page 1 of 1

PHP Date Help

Posted: Mon Aug 02, 2010 6:57 am
by TomG1989
Hi Guys,

I'm not the best coder in the world, i'll attempt new/different things every now and again...

I've created a signup script to a website, where i have added an Update set **sign up's name** into a field called 'datesignup' on my MYSQL Db.

set users datesignup=$now
$now being: $now = date("m-d-y h:i:s A T");

When the user signs up it adds the date of the sign up into a field on a MYSQL DB as desired but..

I'm trying to use this date an replicate it on another page on my website where it shows when the user signed up.

I want it too state "Member for: ** years, ** Months, ** days, **Minutes .... but i cant seem to work out how to do this..

Currently im using print"Member For: $get[datesignup]<br>"; which is stating the date as 08-02-10 07:24:46 AM EDT which is what's being added in the signup script.

Anyone know how i can get this working - Apologise if wrong forum but it's my first post!

Re: PHP Date Help

Posted: Mon Aug 02, 2010 8:33 am
by internet-solution

Re: PHP Date Help

Posted: Mon Aug 02, 2010 10:10 am
by TomG1989
How shall i write it out? Can't get it to work..

the field is $datesignup

Re: PHP Date Help

Posted: Mon Aug 02, 2010 11:15 am
by buckit
just google: php time between dates

you'll find lots of functions that can give you the output you are looking for.

Re: PHP Date Help

Posted: Mon Aug 02, 2010 1:30 pm
by internet-solution
TomG1989 wrote:How shall i write it out? Can't get it to work..

the field is $datesignup
Did you visit the link I posted above? It contains the following sample code:

Code: Select all

<?php

$january = new DateTime('2010-01-01');
$february = new DateTime('2010-02-01');
$interval = $february->diff($january);

// %a will output the total number of days.
echo $interval->format('%a total days')."\n";

// While %d will only output the number of days not already covered by the
// month.
echo $interval->format('%m month, %d days');

?>
The above example will output:

Code: Select all

31 total days
1 month, 0 days