PHP date functions such as strtotime() and time() and date() all return a value as a UNIX TIMESTAMP. This is great for date manipulation but becomes a problem when we need a date to INSERT into a MySQL database. The format of a MySQL TIMESTAMP is yyyy-mm-dd hh:mm:ss and to meet this need a simple PHP can be utilized to convert any UNIX TIMESTAMP into a MySQL TIMESTAMP.
Code and use of function is:
[php]
<?php
/**
*
* @convert UNIX TIMESTAMP to MySQL TIMESTAMP
*
* @param int $timestamp
*
* @return string
*
*/
function unixToMySQL($timestamp)
{
return date('Y-m-d H:i:s', $timestamp);
}
/*** example usage ***/
$time = time();
echo unixToMySQL($time);
?>
[/php]
Thanks for the information, I hardly ever like it.
ReplyDeleteYou have mentioned very interesting details! ps nice web site.
ReplyDeleteSome really nice and useful info on this website, likewise I think the design holds good features.
ReplyDeleteI just want to mention I am just newbie to blogging and site-building and truly liked your page. Likely I’m planning to bookmark your site . You actually come with exceptional posts. Thanks a bunch for sharing your website page.
ReplyDeleteI simply want to say I am newbie to blogging and really enjoyed your blog. Almost certainly I’m want to bookmark your blog . You actually come with perfect articles and reviews. Many thanks for revealing your blog site.
ReplyDeletealong with the new facebook message im not receiving enymore emails when someone sents me a message..why is this occurring?
ReplyDelete