Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

RE: FN-FORUM: php date function

date posted 9th May 2006 16:49

You have a few ways of doing this

First is to get the mysql date yyyy-mm-dd and do an explode() on it

$date_array = explode('-','2006-01-01')

Will give you an array of

$date_array = array(
0 => 2006,
1 => 01,
2 => 01
);


Or look up the mysql date functions

Ash

)))>
----------------------------------------
http://www.extremetropicalfish.co.uk - Aquatics community
http://www.bichirs.info - all things Polypterus
http://www.simplebytes.co.uk - Internet development
-----Original Message-----
From: [EMAIL REMOVED] [EMAIL REMOVED] On Behalf Of Mark Bell
Sent: 09 May 2006 17:33
To: FN-FORUM / [EMAIL REMOVED]
Subject: FN-FORUM: php date function


Afternoon brain teaser:

I'm storing dates in a MySQL table (of last client visits) and want a count
of how many days since the last visit.

I'm storing the date in an 2006-01-01 format.

I've grabbed this: (from http://us3.php.net/date)

$date1 = mktime(0,0,0,1,1,2006);
$date2 = mktime(0,0,0,date('m'),date('d'),date('Y'));
$total_days = 0;
while($date1 < $date2) { $total_days++; $date1 += 86400; }
echo $total_days;

but I guess is need to use something like this:

$date1 = mktime(0,0,0,$lastinmonth,$lastinday,$lastinyear);
$date2 = mktime(0,0,0,date('m'),date('d'),date('Y'));
$total_days = 0;
while($date1 < $date2) { $total_days++; $date1 += 86400; }
echo $total_days;

so how do I convert the 2006-01-01 record in my dB into the 3 required
variables as above? ($lastinmonth,$lastinday,$lastinyear).

or maybe there is another way of outputting it?

I simply want to say, you where in $givendate, today is $todaysdate which is
$dayspast since your last visit.

Thoughts welcome!
Thanks


---
Mark Bell

mob: 0774 086 1862
office: 0870 383 4575
fax: 0870 199 2149
skype: m4rkbell, 020 8123 2862
web: http://m4rk.biz
email: [EMAIL REMOVED]




--
Freelancers, contractors earn more with Prosperity4
Call 0870 870 4414 or visit www.prosperity4.com
and benefit from Inland Revenue approved expenses today.

To advertise here: http://www.freelancers.net/advertising.html



Messages by Day
May 31st 2006
May 30th 2006
May 29th 2006
May 28th 2006
May 27th 2006
May 26th 2006
May 25th 2006
May 24th 2006
May 23rd 2006
May 22nd 2006
May 21st 2006
May 20th 2006
May 19th 2006
May 18th 2006
May 17th 2006
May 16th 2006
May 15th 2006
May 14th 2006
May 13th 2006
May 12th 2006
May 11th 2006
May 10th 2006
May 9th 2006
May 8th 2006
May 7th 2006
May 6th 2006
May 5th 2006
May 4th 2006
May 3rd 2006
May 2nd 2006
May 1st 2006


Messages by Month
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000