0

Hello,

I am just starting to get into mysql and have a quick question: I have a table that has a datetime field, and i simply want to store that datetime into a variable and be able to print it, and also compare it to the current date to see how many days have elapsed. when i run the fetch array command do I have to convert the variable into something else in order to display it on the screen?

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by darkagn
0

Hi frenchwr and welcome to DaniWeb :)

This link will be useful for you, it is the reference manual for MySQL 5.1.

Are you storing the variables in PHP? PHP has a mysql_fetch_array function, which is why I thought this. Or are you working with another language, or purely in MySQL?

0

Hi frenchwr and welcome to DaniWeb :)

This link will be useful for you, it is the reference manual for MySQL 5.1.

Are you storing the variables in PHP? PHP has a mysql_fetch_array function, which is why I thought this. Or are you working with another language, or purely in MySQL?

I am storing the variables in php, then moving them into the database. I just simply am storing a datetime function, and would like to add 7 days to it then store it as another variable in the database if possible.

0

Yes, possible. Use date_add function.

The date_add function is only for PHP version 5.3 or greater. Since 5.3 is due for general release later this year, I assume frenchwr cannot access that function.

What you need to do is use the date and strtotime functions to parse a date for seven days time. Check out this thread in the PHP forum where peter_nichol explains how to use these functions in conjunction with daylight savings. If you still have questions, repost and we will try to help :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.