• Please allow 5 mins between posts.
  • Although email's are required they are hidden.
  • You can create an avatar that will appear everytime you post on a Gravatar enabled blog.
  • You can use the following tags in your post.
    [code][/code] [url][/url] [img][/img] [quote][/quote] [b][/b] [i][/i] [u][/u]

FROM_UNIXTIME

Many of you I'm sure are aware of the mysql command unix_timestamp() to allow a mysql formatted datetime to be outputted in a unixtime stamp

SELECT UNIX_TIMESTAMP(datetime) unixdate FROM Posts;
Which is good but a new function I discovered while trying to link my twitter/digg/post time line to represent the same space of time I need to send a unixtime to MySQL and then translate this to MySQL format. I could of course have still used the UNIX_TIMESTAMP() but I came across a new function, FROM_UNIXTIME() and opted to use this instead.
<?php
$this->Post->find('all', $conditions = array('Post.created <=' => 'FROM_UNIXTIME('.$unixtime.')'));
?>
Simple function to grab all Posts from a particular date onwards. You may also set the format that the unix timestamp will be changed to. FROM_UNIXTIME(timestamp, FORMAT);

SELECT * FROM Users WHERE `created` >= FROM_UNIXTIME({$timestamp}, 'YYYY-MM-DD HH:MM:SS');

No Comments