Convert date from RSS to mySQL format


/ Published in: PHP
Save to your folder(s)

Convert date from RSS to mySQL format


Copy this code and paste it in your HTML
  1. // Thu, 27 Dec 2012 13:35:18 +0000
  2.  
  3. // 2012-12-27 13:35:18
  4.  
  5. $ver = phpversion();
  6. $ver = explode('.',$ver);
  7. $ver = implode(array_slice($ver,0,2));
  8.  
  9. if ($ver>=53) {
  10.  
  11. $date = DateTime::createFromFormat('D, d M Y H:i:s O',$s);
  12. $s = $date->format('Y-m-d H:i:s',$tm);
  13.  
  14. } else {
  15. $tm = strtotime($s);
  16. $s = date('Y-m-d H:i:s',$tm);
  17. }
  18.  
  19. return $s;
  20. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.