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
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Tue Aug 10, 2004 10:19 pm
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?
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Tue Aug 10, 2004 10:25 pm
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.
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Tue Aug 10, 2004 10:42 pm
any more specific solution??
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 10, 2004 10:52 pm
if you want to do the math yourself, UNIX_TIMESTAMP() <- mysql function
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Tue Aug 10, 2004 10:57 pm
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??
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Tue Aug 10, 2004 11:00 pm
The least amount of work you make your users do the better. Make the computer do all the cruddy stuff (math)
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Tue Aug 10, 2004 11:04 pm
Yeah.. but I'am not good enough to ask the computer to do it for me... and the clock is ticking...