Posted By

aristoworks on 10/17/11


Tagged

mysql php time date DateTime api convert twitter


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

boksiora


Convert Twitter API Datetime to MySQL Datetime Format


 / Published in: PHP
 

URL: http://www.aristoworks.com

This is a very rudimentary function used to convert a Datetime delivered by the Twitter API to a format you can store in MySQL's datetime field.

  1. function convert($twitter_datetime = '') {
  2.  
  3. $mysql_format = date("Y-m-d H:i:s", strtotime($twitter_datetime));
  4.  
  5. return $mysql_format;
  6.  
  7. }
  8.  
  9. // SIMPLE USAGE
  10.  
  11. $date = convert("Sat, 15 Oct 2011 00:29:53 +0000");
  12.  
  13. // WILL RETURN 2011-10-14 00:29:53

Report this snippet  

You need to login to post a comment.