Page 1 of 1
MySQL Timestamp
Posted: Tue Feb 13, 2007 7:02 am
by giles
Hi,
I'm having trouble sending a PHP timestamp command to a MySQL database. I'm sending it as a normal query, but somethings not correct. Can you reccomment a simple tutorial or clarify what I should be doing?
Thanks
Giles
Posted: Tue Feb 13, 2007 7:54 am
by onion2k
PHP doesn't have a function for making MySQL timestamps. If you're trying to update a MySQL timestamp column with a unix timestamp (as is generated by things like time() and mktime() ) it won't work because it's the wrong format.
If you want to set a timestamp column (or a date column, or a datetime column) to the time that you're carrying out an insert or update query you can set it to NOW() (eg "update table set myTimestampColumn = NOW() where id = 1;" ).
Posted: Tue Feb 13, 2007 10:16 am
by pickle
The MySQL commands FROM_UNIXTIME() and UNIX_TIMESTAMP() are nice for converting between UNIX & MySQL timestamps.
Your question is very unclear. What does 'sending' mean? What made you think something was incorrect?
Posted: Tue Feb 13, 2007 5:20 pm
by giles
pickle | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thanks for the response ... was getting a bit tied up over the form. For anybody who has an interest my working version is :
[syntax="php"]mysql_query(" UPDATE session
SET
session_end = NOW()
WHERE
session_id = '$session_id' ");
thanks for your time
pickle | Please use[/syntax]Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]