This is a discussion on Convert User entered date and time to Unix Timestamp before inserting to database within the PHP Language forums, part of the PHP Programming Forums category; >Much too complicated, DATE_FORMAT() and UNIX_TIMESTAMP() exist in MySQL. I'm somewhat new to MYSQL, so I agree should ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
>Much too complicated, DATE_FORMAT() and UNIX_TIMESTAMP() exist in
MySQL. I'm somewhat new to MYSQL, so I agree should use existing functions to perform the translations where possible, depending upon your form input. |
|
|||
|
.oO(scotty)
>>Much too complicated, DATE_FORMAT() and UNIX_TIMESTAMP() exist in >MySQL. > >I'm somewhat new to MYSQL OK. ;) >so I agree should use existing functions to >perform the translations where possible, depending upon your form input. Yep. You can do much more things in a query than just the usual SELECTs, even complex calculations and manipulations. If the database is able to do such things and return any data in any particular format you like, why not use it? Keeps the PHP code smaller. Micha |
|
|||
|
Thanks for the tip. There is a lot I'm not aware of. New to MYSQL.
In the recent past I created something that involved dates. I just now changed the data definition you mentioned and it still works fine. The field is now a DATETIME field but is being created with the same TIMESTAMP. So it looks like this functions the same but is now historical rather than the auto-update that you mention? I look forward to going through my edit routines and inserting some of the functions mentioned in these comments, where applicable, to make it more concise where possible. Although I did not ask the original question here, I appreciate the comments and hope that some of my original comments helped as well. |
|
|||
|
.oO(scotty)
>Thanks for the tip. There is a lot I'm not aware of. New to MYSQL. >In the recent past I created something that involved dates. I just now >changed the data definition you mentioned and it still works fine. The >field is now a DATETIME field but is being created with the same >TIMESTAMP. So it looks like this functions the same but is now >historical rather than the auto-update that you mention? There are still important differences. It's all explained in the manual. The DATETIME, DATE, and TIMESTAMP Types http://dev.mysql.com/doc/mysql/en/DATETIME.html TIMESTAMP Properties Prior to MySQL 4.1 http://dev.mysql.com/doc/mysql/en/TI...P_pre-4.1.html TIMESTAMP Properties as of MySQL 4.1 http://dev.mysql.com/doc/mysql/en/TIMESTAMP_4.1.html Micha |