FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Date + Month





DanielXP
How can i get the date and add a month onto it so i can insert it into a database?

i need it becoz i am making a VIP system for my shop Very Happy

Cheers.
Ducksteina
DanielXP wrote:
How can i get the date and add a month onto it so i can insert it into a database?

i need it becoz i am making a VIP system for my shop Very Happy

Cheers.

You can just get the differences between 2 timestamps and calculate the difference between them.
Kaneda
Easiest (and best) way would be to do it on the database side:

mySQL has a whole range of date/time arithmetic functions, so, with a table "mytable" with a field "futuredate" of type "date", you'd do:

Code:
INSERT INTO mytable (futuredate) VALUES (DATE_ADD(NOW(), INTERVAL 1 MONTH))


If you did that right now (and it's still June 8 where you are), the field would contain July 8, 2006. NOW() gets the current date, DATE_ADD() does date arithmetic for you.

If you mean 28 days or something like that, it would just require:

Code:
INSERT INTO mytable (futuredate) VALUES (DATE_ADD(NOW(), INTERVAL 28 DAY))


(yes, "DAY", not "DAYS")

The field would then contain "July 6, 2006".

etc.

You can obviously do it with datetime type too, if you need the exact time of day in addition to the day (i.e., July 8, 2006 21:52:00)
DanielXP
Just need 1 month so will

Code:
INSERT INTO mytable (futuredate) VALUES (DATE_ADD(NOW(), INTERVAL 1 MONTH))


add on a month and put it into the database?
Kaneda
DanielXP wrote:
Just need 1 month so will

Code:
INSERT INTO mytable (futuredate) VALUES (DATE_ADD(NOW(), INTERVAL 1 MONTH))


add on a month and put it into the database?


It will add 1 month to the current date, and store the value in the field "futuredate", yes.
avk
Hey can we get the difference of two dates ??
Eg. Difference between June 2 2006 and June 24 2006 is 22 days.
Such kind of thing.

Can be PHP ot MySql
DanielXP
Yer i need the same thing so i can display there amount of days left
Related topics
Is there a release date for ET:QW
mySQL - Day, date, month, year, time Output/Input
News system with mySQL database.
Exciting web look!
How often do they go in one month into the cinema?
MIDI converter
Pa. Teacher Resigns After Porn Star Date
Spanish date functions in php and mysql
Poll: Sex on first date
Hire your signature for 1 month - 5 frih (or free)
Problem with my script....
Thousands of Files in one Directory
today is 10/10/10
Biorythm ? have you ever heard about that?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.