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!
PHP Date Help
Moderator: General Moderators
-
internet-solution
- Forum Contributor
- Posts: 220
- Joined: Thu May 27, 2010 6:27 am
- Location: UK
Re: PHP Date Help
Clue - strtotime() and http://www.php.net/manual/en/dateinterval.format.php
Re: PHP Date Help
How shall i write it out? Can't get it to work..
the field is $datesignup
the field is $datesignup
Re: PHP Date Help
just google: php time between dates
you'll find lots of functions that can give you the output you are looking for.
you'll find lots of functions that can give you the output you are looking for.
-
internet-solution
- Forum Contributor
- Posts: 220
- Joined: Thu May 27, 2010 6:27 am
- Location: UK
Re: PHP Date Help
Did you visit the link I posted above? It contains the following sample code:TomG1989 wrote:How shall i write it out? Can't get it to work..
the field is $datesignup
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');
?>
Code: Select all
31 total days
1 month, 0 days