What im trying to do is so that when you create a ticket via submit button it
creates a time stamp in mysql db column and than adds the time typed and selected above into it.
and the date/time format im using to display the times is 'F d, Y, g:i A' if its important even though i dont think it is as im just posting not reading XD
Any help would be great sorry if its confusing had trouble trying to explain it XD
Assume you have validated/filtered the user inputs so that $date is the start date/time string in "Y-m-d H:i:s" format, $amount is the integer amount of time to be added, and $unit is a string with one of the values MINUTE, HOUR, DAY, WEEK, MONTH:
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
thanks for the reply that is exactly what im trying to do and it makes alot more sense now. for some odd reason though it isint adding the INTERVAL. i echoed all the variables and they all turn out okay, i even echoed the sql and it ended up like this
could it be because my mysql db column is set to timestamp? should it just be text or something?
as timestamp when i submit it just ends up 0000-00-00 00:00:00
Last edited by Nvenom; 06-17-2011 at 06:06 PM.
Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Things To help you on this Site
1. Place all php code in [php] Tags 2. Place all html code in [html] Tags 3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved
You may need to use TIMESTAMPADD(), instead. (Note the syntax difference/sequence for the arguments.)
(Or, use a DATETIME columns instead of TIMESTAMP if you don't need the special functionality of TIMESTAMP. )
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
i have attempted all of those with no success however i do have another way of doing this i just need a bit more guidance.
Right now it posts like '3' 'DAY' into my table and on my other page it grabs them as variables once again but this time i want to try assign the DATE_add
to a variable is that possible?
right now i have
Code:
$Date = $row[0] // Printed as 2011-06-17 20:30:49 timestamp format
$Pickup = $row[1] // 1,2,3,4,5 etc...
$Pickset = $row[2] // MINUTE, HOUR, DAY etc...
cant seem to plug it in though not even sure if its possible.
Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Things To help you on this Site
1. Place all php code in [php] Tags 2. Place all html code in [html] Tags 3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved
The DATE_ADD() stuff I was referencing is MySQL, not PHP. If you want to do it within your PHP script, it's a different syntax and requires the use of a PHP DateTime object (see http://www.php.net/manual/en/datetime.add.php).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
have any way to convert a mysql timestamp to unix time?
ive tried mktime() but it output the complete wrong value probally because it dosent read 0000-00-00 00:00:00 format properly and i have to break it up right?
Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Things To help you on this Site
1. Place all php code in [php] Tags 2. Place all html code in [html] Tags 3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved
thanks a bunch i realize this was really stretched out lol XD
Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Things To help you on this Site
1. Place all php code in [php] Tags 2. Place all html code in [html] Tags 3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved
Bookmarks