将Twitter API Datetime转换为MySQL Datetime格式

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将Twitter API Datetime转换为MySQL Datetime格式相关的知识,希望对你有一定的参考价值。

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

以上是关于将Twitter API Datetime转换为MySQL Datetime格式的主要内容,如果未能解决你的问题,请参考以下文章