PHP Unix TimeStamp to mySQL DATETIME

///PHP Unix TimeStamp to mySQL DATETIME

PHP Unix TimeStamp to mySQL DATETIME

\r\nSometimes you jut want to have a ready need to take a recalculated timestamp from a past/future date and store it in your DB this little function helps achieve that, I notice a lot of people especially newer coders who have a passion for time() timestamps as they are in a sense easier to work with, but at the end of the day don’t know how to switch it over to a mySQL friendly datetime format Example:\r\n\r\nTimeStamp: 1306193250 converts to MySQL DATETIME: 2011-05-23 19:27:30\r\nTimeStamp: converts to MySQL DATETIME: \r\n\r\n\r\nNow some may argue that its a bit redundant to have this in function format as all it really is, is one line of code, however I keep it as a function to remember it easier. When the time comes to use it rather than type everything all out time and time again. But thats just me.\r\n\r\n
\r\nfunction unixToMySQL($timestamp)\r\n{\r\n	return date('Y-m-d H:i:s', $timestamp);\r\n}\r\n
By | 2012-03-08T15:50:18+00:00 March 8th, 2012|Code, PHP|0 Comments

About the Author:

Not much to know about me, I'm a 35+ year old coder, geek, gamer..

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: