Convert Twitter API Datetime to MySQL Datetime Format


/ Published in: PHP

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.


Copy this code and paste it in your HTML
  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

URL: http://www.aristoworks.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.