date mathematical operation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

date mathematical operation

Post by g3ckO »

I stored the date in MySQL using date format (yyyy-mm-dd)

How can I do a mathematical operation on it.

As an example, I want to count the total day from $dateStart = (2004-08-22) to $dateEnd = (2004-08-27).
How should I write it?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Google "MySql compare dates" or check out mysql.com or search this forum there have been many topics regarding this.
Last edited by hawleyjr on Tue Aug 10, 2004 10:44 pm, edited 1 time in total.
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

any more specific solution?? :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if you want to do the math yourself, UNIX_TIMESTAMP() <- mysql function
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

I have read many article about UNIX_TIMESTAMP() but its quite hard for me to understand it.

But my friend have give me better solution I think. He told me why not just ask the user to key in the total day in the form.
What your opinion??
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

The least amount of work you make your users do the better. Make the computer do all the cruddy stuff (math)
User avatar
g3ckO
Forum Contributor
Posts: 117
Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:

Post by g3ckO »

Yeah.. but I'am not good enough to ask the computer to do it for me... and the clock is ticking... :)
Post Reply