Convert MySQL date to UNIX timestamp


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



Copy this code and paste it in your HTML
  1. <?php
  2. // from MySQL to UNIX timestamp
  3. function convert_datetime($str)
  4. {
  5.  
  6. list($date, $time) = explode(' ', $str);
  7. list($year, $month, $day) = explode('-', $date);
  8. list($hour, $minute, $second) = explode(':', $time);
  9.  
  10. $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
  11.  
  12. return $timestamp;
  13. }
  14. ?>

URL: http://www.vision.to/convert-mysql-date-to-unix-timestamp.php

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.