Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

timestamp arithmatic

Status
Not open for further replies.

ftsw

Technical User
Sep 17, 2002
9
0
0
US
A user can only vote once per year. $uvote is a timestamp(12) datatype. I was thinking $today=time();$uvote=$today;
Does $nextyr=$uvote+1year? How do you handle this with code?
 
From the timestamp column type, I'm assuming your backend is MySQL.

If you want to calculate a future date, you can do so using MySQL's DATE_ADD() function (
You can also do it from within PHP. Since PHP's time() function returns an integer representation of the date in seconds since 1970-01-01 00:00:00, you can add 31536000 (365 * 24 * 60 * 60) to it to calculate a date for next year. If you need to turn the integer into a string, PHP's function date() ( is available. ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top